uilabel

How to do multiline UILabel in ios?

霸气de小男生 提交于 2019-12-20 09:11:13
问题 I'm dynamically populating the title (UILabel). Sometime it's bit too long and IOS squeeze the font to fit in the width. Is there a way to do multiline with using same font size? 回答1: Set adjustsFontSizeToFitWidth to NO and numberOfLines to 0. numberOfLines Docs This property controls the maximum number of lines to use in order to fit the label’s text into its bounding rectangle. The default value for this property is 1. To remove any maximum limit, and use as many lines as needed, set the

NSAttributedString ignores Autoshrink and numberOfLines for UILabel (iOS 6)

别说谁变了你拦得住时间么 提交于 2019-12-20 08:48:21
问题 I have UILabel with number of lines = 2 system font size = 15 minimum font size = 8 Line break mode - Truncate tail When I set long text which have type NSString for UILabel it works fine and shows multiline text (scaled if needed). When I am trying to set text with type NSAttributedString it ignores minimum font size and Autoshrink so I see one line text with maximum font size. Is it possible to solve this problem Looks something like this (Label size is const) ----------------------- |

How to set background color to UILabel text only

不想你离开。 提交于 2019-12-20 07:40:07
问题 I'm working the App where i need to set the label like attached image. Please let me know if anyone have any idea? 回答1: You can do like this NSString *yourString1=@"What Does your friends really"; NSString *yourString2=@"Think of your spouce?"; NSString *str1=[NSString stringWithFormat:@" %@..\n",yourString1]; NSString *str2=[NSString stringWithFormat:@" %@,,",yourString2]; NSString *str3=[NSString stringWithFormat:@"%@%@",str1,str2]; NSMutableAttributedString *attributedString = [

UITextField to Int to UILabel

北战南征 提交于 2019-12-20 07:39:27
问题 I'm used to C# and java, swift is definitely a different beast! I've been struggling for hours trying to get this to work. It is something so simple as well! I just want to get the text from a UITextField and turn it into an Int and then send the Int to a UILabel!! So many answers on the internet haven't worked at all! This is the error i'm getting now. ( using Xcode 8.2.1 and Swift 3.0.2 ) import UIKit class ViewController: UIViewController { @IBOutlet weak var firstTextField: UITextField!

my initial problems with UIScrollView now appear to be related to autolayout

时光总嘲笑我的痴心妄想 提交于 2019-12-20 07:14:18
问题 For my first challenge using UIScrollView I modified this example to make UIScrollView display not just another background colour but another UIView and UILabel on each page. But I could have just as easily chosen to display objects like UITableView , UIButton or UIImage . Potentially, UIScrollView could be much more than a giant content view where users scroll from one part to the next, e.g., some pages might have a UIButton that takes a user to a specific page, the same way we use books.

How do I achieve a clearly rendered rotated UILabel?

强颜欢笑 提交于 2019-12-20 05:43:06
问题 I am trying to display rotated text. The UILabel is added as a subview on a UIImageView. The UIImageView has a transform created via say CGAffineTransformMakeRotation(M_PI/4.0). The text of the UILabel renders fairly blurry cf. the title label (in the screenshot, the blue background 'What's ...'). Do you know how I can manage to make the rotated text render clearly? I've already tried using an integral-based frame (which matters little since it'll be rotated), a non-clear background color,

My button is centered for iPhone 6 and 6 plus, but not for iPhone 5

谁都会走 提交于 2019-12-20 04:56:16
问题 I do have autolayout on, but for some reason my center button isn't being centered for other phone sizes. I have constraints set and like I mentioned autolayout, so I'm somewhat confused. All other items are where they should be, buttons, other labels, etc. One specific label at the top is just off center for all models aside from iPhone 6. 回答1: If I am not wrong you didn't add any constraint to your label that's why it is not at center. Add this constraint for label. Result for all screen:

Decimal point alignment in iOS UILabel during countdown?

一笑奈何 提交于 2019-12-20 04:23:40
问题 Sorry I don't have any code yet, but would appreciate some advice! I have a countdown timer showing seconds with one decimal point in a UILabel (10.0, 9.9, 9.8, etc.). It works fine, but the decimal point moves around slightly depending on the size decimal value. Is there a way to align the text in the UILabel to the decimal point or should I create two labels (one for the seconds value aligned right and one for the decimal value aligned left)? Thanks! 回答1: I think your suggestion of multiple

UIView dynamic height depending on Label Height

六月ゝ 毕业季﹏ 提交于 2019-12-20 03:38:34
问题 I have a Label which takes dynamicaly some data from database. These data are strings which can sometimes be 3-4-5 rows etc. So this labe is inside a UIView. --UIView --Label How can i make the UIView to take the certain height of the Label dynamicaly?? 回答1: you can just do it with storyboard this pics set the label height relation to greater than or equal and set the view height relation to greater than or equal it work like a magic 回答2: Bellow is working solution of your problem. I used

How to update UILabel programmatically in iOS

和自甴很熟 提交于 2019-12-20 02:57:09
问题 I am facing a problem with updating my labels.. it doesn't remove the old values so new values go on top of old ones.. any help with this will be appreciated.. timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateLabels) userInfo:nil repeats:YES]; -(void) updateLabels{ for (GraphView *graph in arr){ // retrieve the graph values valLabel = [[UILabel alloc] initWithFrame:CGRectMake(i * 200, 0, 90, 100)]; valLabel.textColor = [UIColor whiteColor]; valLabel