uilabel

Detect URL in NSString

本小妞迷上赌 提交于 2020-01-03 10:56:32
问题 I'm currently using a UITextView in a UITableViewCell in order to make links clickable, but this is giving very poor performance. So I was wondering if it's possible to detect links in a NSString and if there is a link, use the UITextView , otherwise just use a UILabel . 回答1: Absolutely. Use NSDataDetector (NSDataDetector Class Reference) 回答2: I guess you are familiar with regexes to detect URLs, so in order to get one or the other type of view in your cell, you can simply return two

How do I turn off large titles for UINavigationBar?

安稳与你 提交于 2020-01-03 06:48:14
问题 I have a UITableView and a Detail View embedded in a UINavigationController as so: I would like to turn on large titles for "My Notes" but I'd like to turn it off for the detail view. Something like how the default Mail app works on iPhone. How would I change the navigation bar's prefersLargeTitle property during that segue? 回答1: it's very simple. In your DetailView you should set navigationItem.largeTitleDisplayMode to .never (not navigationController?.navigationItem.largeTitleDisplayMode !!

How to convert unicode hex number variable to character in NSString?

混江龙づ霸主 提交于 2020-01-03 03:52:04
问题 Now I have a range of unicode numbers, I want to show them in UILabel, I can show them if i hardcode them, but that's too slow, so I want to substitute them with a variable, and then change the variable and get the relevant character. For example, now I know the unicode is U+095F, I want to show the range of U+095F to U+096f in UILabel, I can do that with hardcode like NSString *str = [NSString stringWithFormat:@"\u095f"]; but I want to do that like NSInteger hex = 0x095f; [NSString

How to resolve this error? - Class 'ViewController' has no initializers

六月ゝ 毕业季﹏ 提交于 2020-01-02 08:18:13
问题 I have created UILabel programmatically in swift but it gives me following error : Class 'ViewController' has no initializers Code : class ViewController: UIViewController { let lbl_LastName: UILabel! override func viewDidLoad() { super.viewDidLoad() lbl_LastName.frame = CGRectMake(10, 230, 300, 21) self.view.addSubview(lbl_LastName) } } 回答1: change let lbl_LastName: UILabel! to var lbl_LastName: UILabel! 来源: https://stackoverflow.com/questions/31780647/how-to-resolve-this-error-class

UILabel and superscript

泄露秘密 提交于 2020-01-02 06:19:24
问题 I have two strings: a variable length piece of text another string with numbers that point to a reference In my view, the first piece of text is displayed in a UILabel, I adjust the size of the label to accomodate the size of the text. This means I cannot just place another UILabel on the screen, at least not without repositioning it...somehow. I need to be able to put the second piece of text so it appears to be at the end of the sentence - and superscripted I really have no idea how to

Is it possible to make UILabel with non-English characters green when Color Blended Layer is enabled?

老子叫甜甜 提交于 2020-01-02 03:37:13
问题 I have a table view with custom cells and I try to optimize it by making all subviews inside the cells in green color when Color Blended Layer is checked in the simulator. When the background of an UILabel in the cell is set to white: let title = UILabel() contentView.addSubview(title) title.background = UIColor.whiteColor() title.text = "Hi, how are you?" This UILabel subview will become green color in the simulator, which is good. However, if I change the text to some Chinese: title.text =

UILabel in a UITableViewCell With Dynamic Height

不想你离开。 提交于 2020-01-02 02:21:09
问题 I'm having some problems implemented dynamic row heights in a UITableView - but it isn't the cells that I'm having a problem with, its the UILabel inside of the cell. The cell just contains a UILabel to display text. My tableView:heightForRowAtIndexPath: is correctly resizing each cell by calculating the height of the label that will be in it using NSString's sizeWithFont: method. I have a subclass of UITableViewCell that just holds the UILabel property that is hooked up in storyboard. In

Is it possible to add a UILabel or CATextLayer to a CGPath in Swift, similar to Photoshop's type to path feature?

血红的双手。 提交于 2020-01-02 00:12:59
问题 I would like to add text, whether it be a UILabel or CATextLayer to a CGPath . I realize that the math behind this feature is fairly complicated but wondering if Apple provides this feature out of the box or if there is an open-source SDK out there that makes this possible in Swift. Thanks! Example: 回答1: You'll need to do this by hand, by computing the Bezier function and its slope at each point you care about, and then drawing a glyph at that point and rotation. You'll need to know 4 points

How to make UITableViewCell with 2 labels of different color?

╄→гoц情女王★ 提交于 2020-01-01 05:20:31
问题 I would like to have UITableViewCell like this: The text color of "Tel:" must be different from text color of number. Right now i set text to cell as usual: cell.textLabel.text=@"Something"; Is it possible to have 1 label and change color of some parts of it? How can I make table cell like on my picture? Thank you. 回答1: You should have to take two Labels and in Cell...and add this both Label in subview of UITableViewCell Write this in cellForRowAtIndexPath method. - (UITableViewCell *

Is UILabel Inset effect Possible? [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 05:19:13
问题 This question already has answers here : UILabel text margin [duplicate] (38 answers) Closed 6 years ago . I am giving border to UILabel with Label.text = lbltext; Label.layer.borderColor = [[UIColor grayColor] CGColor]; Label.layer.borderWidth = 2; But There is no space between text and border. so how can i set inset effect like UIButton in my Label? 回答1: Put the label in a container view and apply the border to the container. 回答2: You can subclass UILabel, and override a couple of methods: