uilabel

iPhone: How to make a tip balloon programmatically?

穿精又带淫゛_ 提交于 2019-12-06 15:30:49
Please provide the code to make a tip balloon programmatically, like Grindr has. I want it to be sized automatically, based on the text & font-size. And, I want to be able to change the location of the arrow. If it's on an end, it should be a right triangle. Otherwise, it should be an eqilateral triangle. // AppDelegate.h @interface AppDelegate : NSObject <UIApplicationDelegate> { } @property (nonatomic, retain) UIWindow *window; @end // AppDelegate.m #import "AppDelegate.h" #import "TipBalloon.h" @implementation AppDelegate @synthesize window; #pragma mark NSObject - (void)dealloc { [window

UILabel height?

若如初见. 提交于 2019-12-06 14:57:40
问题 I have an uilabel setup with IB and with this code: // setup label sv.text = @"When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.When in the

Border around every word of UILabel

孤者浪人 提交于 2019-12-06 14:53:09
问题 Is there a way i can draw border around every word of UILabel . Suppose UILabel contains the string " This is the Line 1". I want 5 different border around 5 words This Is the Line 1 回答1: I am not aware of an easy to use code for UILabel, but for UITextView: Swift playground setup: import UIKit let string = "Lorem ipsum dolor sit amet" let textView = UITextView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) textView.text = string use regular expressions get a match for every word: let

iOS/Objective-C UILabel text kerning

岁酱吖の 提交于 2019-12-06 14:51:27
问题 I was in search of how to increase character spacing in UILabel s to make more attractive my UI Design implementations for the Apps I do. And I found following answer, which tells it allows to adjust the Text Kerning, and it's written in Swift . But what I needed is an Objective-C Solution. So I tried to convert the following code snippet: import UIKit @IBDesignable class KerningLabel: UILabel { @IBInspectable var kerning:CGFloat = 0.0{ didSet{ if ((self.attributedText?.length) != nil) { let

UILabel Not Updating When Returning to UIViewController

天涯浪子 提交于 2019-12-06 14:28:22
问题 I have a simple app that has an NSTimer object in the appDelegate to be accessed by all views. The structure of the app is with a UINavigationController. When I fire the NSTimer object, my UILabel is being updated with the correct countdown function, but when I go back to the rootViewController and back to the countdown timer view, my UILabel is being updated with the current countdown time, but no subsequent updates to the UILabel happen. What am I missing? I have done research on making

Multi-colored UILabel text

南楼画角 提交于 2019-12-06 14:07:46
Is is possible to create multi-colored text within a UILabel? I.e, if my text was: "The quick brown fox" have the q and b in blue with the rest of the text in black? I get the feeling I'd have to use a UIWebView and render the text in HTML to accomplish this. Thoughts? You are correct that you need to use a UIWebView. Alternatively, you can draw the text yourself into a custom view, but that would probably be a lot more difficult to implement. If you are going to draw it yourself, you'll want to use the drawing methods in NSString UIKit Additions along with the -[UIColor set] method etc.

UITableViewCell reorganize subviews when the 'delete' button appears

牧云@^-^@ 提交于 2019-12-06 13:35:43
问题 Does anyone knows any method to resize subviews(I.E. UILabelView) when Delete button appears. There could be two methods: 1.Capture a notification, if there's one, when the button appears in the UITableViewCell 2.Tell the framework re-arange it automatically. 回答1: In your UITableViewCell class's .m file use layoutSubviews. It is called every time the cell is resized, the delete button appears/disappears, and more: - (void) layoutSubviews { [super layoutSubviews]; frame = self.contentView

Get string of first line in a UILabel

六月ゝ 毕业季﹏ 提交于 2019-12-06 11:16:59
问题 I have some text in a UILabel . I want to get the text of the first label in a string variable. For example: label.text = @"You make an object by creating an instance of a particular class. You do this by allocating the object and initializing it with acceptable default values. When you allocate an object, you set aside enough memory for the object and set all instance variables to zero. Initialization sets an object’s initial state—that is, its instance variables and properties—to reasonable

UILabel - set custom fonts

放肆的年华 提交于 2019-12-06 10:42:43
问题 I want to add GillSans-Bold font to a UILabel. I have set it in the xib file , and I'm also setting it up in my class as follows : [label setFont:[UIFont fontWithName:@"GillSans-Bold" size:18]]; But , it doesn't seem to work for me. Any suggestions ? 回答1: iPhone 4.3 doesn't have Gill Sans, but iPad has it since 3.2.1. See this list comparing fonts for iPad 4.3 and iPhone 4.3. To be sure, this is how you get the list of fonts available on your device: for (NSString *familyName in [UIFont

iOS/Swift: Can't assign optional String to UILabel text property

徘徊边缘 提交于 2019-12-06 10:01:43
问题 UILabel has a text property, which is an optional String, but it seems to be behaving like an implicitly unwrapped optional. Why can't I assign it another optional String? Thanks. @IBOutlet weak var tweetContent: UILabel! ... var unopt: String = "foo" var opt: String? = "bar" var opt2: String? opt2 = opt //Works fine cell.tweetContent.text? = unopt //Works fine cell.tweetContent.text? = opt //Compile error: Value of optional type 'String?' not unwrapped 回答1: You don't need to unwrap text .