uilabel

iPhone iOS UILabel how to customize text color for UITableView detail text labels only?

霸气de小男生 提交于 2019-12-10 11:14:07
问题 I'm working on an interface prototype and am using a storyboard to do so. Part of the prototype involves setting the detail UILabel for UITableView cells to a certain color. I would like to avoid having to manually recolor every label within a storyboard. I found that I can use: [[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] setTextColor:[UIColor cyanColor]]; To change the appearance of labels within tableview cells. Is there a way to further refine this code to only apply

Difference between “.text” and “setText:”? [duplicate]

我怕爱的太早我们不能终老 提交于 2019-12-10 10:17:41
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Is there a difference between setting a property with the dot or the bracket syntax? If I define a label in the .h file and I want to change the text of it in the .m file, is there really a difference between using label.text = @"..." and [label setText:@"..."] ? They appear to do exactly the same thing, and if that's the case, then why the different ways to do it? 回答1: There is no difference in the inner

Resizing UIStackView after changing UILabel number of lines

拟墨画扇 提交于 2019-12-10 10:13:42
问题 My iOS app has a tableview with one UITableViewCell with the following layout (1 stackview containing 2 labels and 1 button) When the user taps the button the number of lines of the central label goes from 0 to 2 and will look like this: Now there are two problems here: 1) Resizing the UIStackView 2) Resizing the cell I have found a not-optimal solution for problem 1, which consists of adding an empty view in the stack. (invalidateIntrinsicContentSize was not working). let emptyView = UIView(

sizeToFit is functioning oddly

為{幸葍}努か 提交于 2019-12-10 10:07:37
问题 I have a segment of code that gets executed everytime a backend database change occurs. Essentially I have a label inside of a parent view. The label gets updated by one of many status messages each one on a different line ended by a new line (\n). Each status message needs to be on one line only and not go over. The problem I am having is that everything works fine when the View first reloads. However when I am on the screen and a change occurs in background, once in a while a status message

iOS 8 UITableView first row has wrong height

落花浮王杯 提交于 2019-12-10 03:38:40
问题 I'm working on an app where I face a strange issue. I've created a UITableViewController in the storyboard and added a prototype cell. In this cell, I've added an UILabel element and this UILabel takes up the whole cell. I've set it up with Auto Layout and added left, right, top and bottom constraints. The UILabel contains some text. Now in my code, I initialize the the rowHeight and estimatedRowHeight of the table view: override func viewDidLoad() { super.viewDidLoad() self.tableView

iOS. Determine last line width of UILabel

爱⌒轻易说出口 提交于 2019-12-10 02:09:36
问题 guys! I have a label with multiple lines, lineBreakMode is set to UILineBreakModeWordWrap. How can I determine width of last line? Thanks 回答1: Here's how I did it. First put your label's lines in NSArray, and then check width of last line. In viewDidLoad: NSArray* lines = [self getSeparatedLinesFromLbl:srcLabel]; NSString *lastLine=[lines lastObject]; float lastLineWidth=[lastLine sizeWithFont:srcLabel.font constrainedToSize:boundingSize lineBreakMode:NSLineBreakByWordWrapping].width; And

How to get preferred AutoLayout height given a width for a collection view cell with multiline labels?

牧云@^-^@ 提交于 2019-12-09 22:42:07
问题 I'm building a list view with self-sizing in my app using UICollectionView . Getting UICollectionViewFlowLayout to do a vertical list layout is a pain, so I'm writing my own UICollectionViewLayout subclass to do it. My cells look a lot like regular table view cells - an image view on the left, a couple of labels vertically stacked in the center, and an accessory view on the right. The labels can wrap to a few lines and grow in font size according to the system font size setting, which is why

UILabel: adjust font size to height with AutoLayout

為{幸葍}努か 提交于 2019-12-09 20:08:34
问题 I'd like to have several labels one below the other. The are sized with AutoLayout, I'd like to have the font size as big as possible. adjustsFontSizeToFitWidth only works for the width, but the I get the following result 回答1: You can re-calculate your content height by calling (it may be a little easier to manage by having your layout built as a tableview, if it isn't already): [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingExpandedSize].height; I've also had to hard code this

iOS UILabel use negative background color as text color

和自甴很熟 提交于 2019-12-09 16:55:15
问题 I don't know any buzz word for this technique, so I was not lucky to find something in search engines. I want to achieve an effect, that makes an UILabel use the nagative color of the background for its text color, (black and white like in the picture would be enough for my purpose). By using attributedText I could color every letter, but as you can see in this picture, I want an effect that can lead to different colors for a single letter. My best guess would be to rasterize the label and

UIWebView in UITableViewCell getting refreshed while scrolling

核能气质少年 提交于 2019-12-09 14:12:52
问题 I've a custom UITableViewCell with UIWebview to display the hyperlink text in user's activity (ref. attached image).UIWebView generally takes a sec to load HTML data. Also during scrolling, UIWebView will get refreshed again and it take a sec more, which looks very odd. I tried FancyLabel, but not able to achieve the same result. Any help would be appreciated. 回答1: Try NSAttributedString for this problem. Follow the mentioned links : http://developer.apple.com/library/mac/#qa/qa1487/_index