uilabel

UILabel over UIProgressView with multiple colors

橙三吉。 提交于 2019-12-10 21:51:27
问题 So I haven't done this yet, I'm trying to play out how to do this. So I make a UITableView and each cell has an associated NSTimer. Now in each custom UITableViewCell I have a UIProgressView as the background, stretched to fill the cell. Now I want to add a UILabel with remaining time onto of the UIProgressView. But since the progress bar fill color and background color are dramatically different (navy blue progress fill and white background/non filled area), I'm wondering how to dynamically

UILabel sizeToFit only works with AutoLayout turned off

非 Y 不嫁゛ 提交于 2019-12-10 21:19:19
问题 So I am making an app using iOS 6 and was wondering why my code that used to work great on iOS 5 does not work anymore. I have a cell with dynamic UILabel that gets adjusted based on the text that it carries. This is with autolayout turned on: This is with autolayout turned off: Here is my code: - (CGFloat)heightForText:(NSString *)bodyText { #define FONT_SIZE 13.0f #define CELL_CONTENT_WIDTH 280.0f #define CELL_CONTENT_MARGIN 5.0f CGSize constraintSize = CGSizeMake(CELL_CONTENT_WIDTH - (CELL

How to know the displayed text in UILabel?

让人想犯罪 __ 提交于 2019-12-10 21:06:48
问题 I have an UIView containing two UILabels , in order to display a string. The first UILabel has a fixed size, and if the string is too long and can't hold in this UILabel , I want to display the maximum characters I can in the first UILabel , and display the rest of the string in the second UILabel . But to make this, I must know the exact part of the string displayed in the first UILabel , which is not easy because of the randomness of the string and the linebreaks. So, is there a way to get

Borders not covering background

倾然丶 夕夏残阳落幕 提交于 2019-12-10 20:21:35
问题 I've got a UILabel is using a border the same color as a background which it is half obscuring, to create a nice visual effect. However the problem is that there is still a tiny, yet noticeable, sliver of the label's background color on the OUTSIDE of the border. The border is not covering the whole label! Changing the border width doesn't change anything either, sadly. Here's a picture of what's going on, enlarged so you can see it: And my code follows: iconLbl.frame = CGRectMake(theWidth/2

Why doesn't the storyboard reflect the text attributes I've set to a UILabel using the attributes inspector panel?

半世苍凉 提交于 2019-12-10 18:12:29
问题 I have a UILabel on the storyboard. The default text reads "Label". I then go to the attributes inspector and select the Attributed text style. When I click on the Text field I am presented with several fonts to choose from in a new window. I see that the default text in this case has been set to Helvetica size 17.0. When looking through the fonts presented I decide to use one called ORC A Std. This is part of the fixed width family. Since I want to use this font, I go back into my attributes

Center footer UILabel in grouped UITableView - Swift

北战南征 提交于 2019-12-10 17:56:51
问题 I'm currently adding an information page to my app, and wish to display the version number of the app centred in the footer of a grouped UITableView. I have it displaying, but I'm not sure how to go about centring it. I've looked at using the tableviews viewForFooterInSection; would this be the correct way going forward, or is there a simpler way? Many thanks in advance. 回答1: Simply just add a footer to your tableView and it will be placed at the bottom, no matter how many sections you have

Scale UISegmentedControl labels based on width of control

a 夏天 提交于 2019-12-10 17:49:55
问题 This seems like a no brainer, but I cannot find any way to do this. Basically what I have is a UISegmentedControl with two localized labels using NSLocalizedString . I have set the font size and everything looks great in English and a few other languages. But, in Japanese and other languages the characters are larger and cause the label to be truncated. self.segmentedControl = [[UISegmentedControl alloc] initWithItems: [NSArray arrayWithObjects: NSLocalizedString(@"Miles", nil)

Programmatically moving a UILabel in a xib file

喜夏-厌秋 提交于 2019-12-10 17:25:24
问题 Problem: My UILabel is not moving after I change its frame information but after outputing with NSLog the frame info matches the correct position, yet the label itself does not actually move. More Info: I'm trying to move a UILabel to the same position as a UITextField. Both are contained in a XIB file. I can update the text just fine, and outputting frame information would indicate that the label has moved to the correct position but when you actually look on the screen you can see the label

UIImage in the end of UILabel text

▼魔方 西西 提交于 2019-12-10 15:55:06
问题 how to find coordinate of the last character in UILabel if we have more then 1 line of text in it? I would like to add an image in the end of the text. 回答1: I think you are looking for NSTextAttachment // create an NSMutableAttributedString let fullString = NSMutableAttributedString(string: "Your text") // create our NSTextAttachment let imageAttachment = NSTextAttachment() imageAttachment.image = UIImage(named: "icon") // wrap the attachment in its own attributed string so we can append it

How can I prevent orphans in a label in swift?

给你一囗甜甜゛ 提交于 2019-12-10 15:43:40
问题 I have a label that can have one or two lines. If it has two lines, I want the second line to have at least two (or maybe three) words, never just one. Any ideas about how I can accomplish that using swift? Thanks in advance! Daniel Edit: I edited out my silly first thoughts that didn't really help. 回答1: Ok, after looking around a lot I came up with what I think is the best solution. I wrote this function: func numberOfLinesInLabelForText(text: String) -> Int { let attributes =