uilabel

UILabel + IRR, KRW and KHR currencies with wrong symbol

核能气质少年 提交于 2019-12-30 05:24:25
问题 I'm experiencing issues when converting decimal to currency for Korean Won, Cambodian Riel and Iranian Rial and showing the result to the UILabel text. Conversion itself passes just fine and I can see correct currency symbol at the debugger, even the NSLog prints the symbol well. If I assign this NSString instance to the UILabel text, the currency symbol is shown as a crossed box instead of the correct symbol. There is no other code between, does not matter what font I use. I tried to print ₩

UILabel: Custom underline color?

喜夏-厌秋 提交于 2019-12-30 04:21:15
问题 I need the text of a UILabel to be black, but have a light gray underline under the text. Is this possible with NSAttributedString or TTTAttributedLabel ? Or is custom drawing using Core Graphics needed? CLARIFICATION: I need a specific color text on a different color underline. Example: blue text on red underline. 回答1: You can do with NSAttributedString as below. NSMutableAttributedString* string = [[NSMutableAttributedString alloc]initWithString:@"you string"]; [string addAttribute

UILabel cuts off custom font. How do I dynamically adjust UILabel height based on custom font selected?

╄→尐↘猪︶ㄣ 提交于 2019-12-30 01:55:09
问题 Some of the custom fonts I've loaded onto my app are getting cut off when displayed in a UILabel. I have multiple custom fonts that I need to properly display. How can I fix this? 回答1: As stated, I had a very annoying problem where custom fonts in a UILabel would get cut off due to something . I later found out it was due to ascenders and descenders (font characteristics). After much searching I found a solution that required you to download a program, adjust the font's ascender and descender

How can I compute the number of lines of a UILabel with a fixed width? [duplicate]

断了今生、忘了曾经 提交于 2019-12-30 00:35:08
问题 This question already has answers here : How to find UILabel's number of Lines (7 answers) Closed 6 years ago . How can I compute the number of lines of a UILabel with a fixed width and a given text ? 回答1: This code assumes label has the desired text and its frame is already set to the desired width. - (int)lineCountForLabel:(UILabel *)label { CGSize constrain = CGSizeMake(label.bounds.size.width, FLT_MAX); CGSize size = [label.text sizeWithFont:label.font constrainedToSize:constrain

善用代码片段提升开发效率

十年热恋 提交于 2019-12-29 18:31:42
一.什么是代码片段( code snippets ) 代码片段:指用来存放 程序 执行代码的一块内存区域。 诸如很多开发工具基本都集成了这一功能,可以说你在 coding 的时候经常都在使用它,或许你不知道你在使用的正是 snippet 的功能,比如你在开发工具中写代码的时候,用到 if , for , while 等循环体是,基本都不是自己把整块完整的写出来,而是通过编译器的提示自动填充剩余部分的代码。这也就是所谓的代码片段( code snippets )。 二.在 xcode 中如何使用代码片段 首先来说说我们平时在写 UI 的时候是怎么写的。 比如一个 UILabel 或者比如一个 UIButton 这都是我们在开发 UI 的时候频繁使用的基础控件,基本上每个页面都会蕴含很多这样的控件,也就意味着我们需要写很多次一样的代码。也许有人说可以把 UILabel 封装一下,但是在实际开发中,需求是各种各样的,基本上还是需要对几个通用的属性进行赋值。在这里先不讨论这个话题。想想即使是一个熟练的 coder ,敲下这片代码,或许还是需要一两分钟的时候,这前提还是需要有一双好的键盘手呐! 下面引入 code snippets 的话题。 在我们平时开发的过程中写一个 for 循环,我们只需要输入 for ,然后剩余的代码只需要根据编译器的提示进行自动填充。这样的效率是很高的呐

UIButton's Title Label Word Wrap with Tail Truncation

余生颓废 提交于 2019-12-29 14:19:45
问题 I need to enable word wrapping and tail truncation, at the same time, on a UIButton 's titleLabel . Setting numberOfLines to something more than 0 doesn't work, the text stays on one line. I've already searched around and haven't found a solution. Any idea? 回答1: This is not correct: lblTemp.lineBreakMode = NSLineBreakByWordWrapping | NSLineBreakByTruncatingTail lblTemp.numberOfLines = 0; NSLineBreakMode is defined in NSParagraphStyle.h as: typedef NS_ENUM(NSInteger, NSLineBreakMode) { /* What

How to increase the character spacing in UILabel

試著忘記壹切 提交于 2019-12-29 12:12:11
问题 I am creating an app in >=iOS6. And I want to change the character spacing in UILabel. I have added the custom font "FUTURABT HEAVY" in my app but the Character are too close to eachother. I have find the good code here to increase the character spacing. But if i tried to change it than my text became left- align in stead of center. Please help me with this situation. 回答1: You should probably use NSAttributedString with NSKernAttributeName attribute Here is a small example: UILabel *label = [

iOS: set font size of UILabel Programmatically

耗尽温柔 提交于 2019-12-29 10:47:30
问题 I'm trying to set the font size of a UILabel. No matter what value I put though the text size doesn't seem to change. Here's the code I'm using. [self setTitleLabel:[[UILabel alloc] initWithFrame:CGRectMake(320.0,0.0,428.0,50.0)]]; [[self contentView] addSubview:[self titleLabel]]; UIColor *titlebg = [UIColor clearColor]; [[self titleLabel] setBackgroundColor:titlebg]; [[self titleLabel] setTextColor:[UIColor blackColor]]; [[self titleLabel] setFont:[UIFont fontWithName:@"System" size:36]];

Text not displaying on UILabel when the text is too large.

ε祈祈猫儿з 提交于 2019-12-29 07:35:28
问题 I have a text (Story of a book). I am taking UILabel to display it. But it is not showing me on view. I am using the following code: CGSize labelsize; UILabel *commentsTextLabel = [[UILabel alloc] init];; [commentsTextLabel setNumberOfLines:0]; commentsTextLabel.textColor = [UIColor blackColor]; [commentsTextLabel setBackgroundColor:[UIColor clearColor]]; [commentsTextLabel setFont:[UIFont fontWithName:@"ACaslonPro-Regular"size:17]]; labelsize=[story sizeWithFont:commentsTextLabel.font

Lines missing from tall UILabel when embedding NSTextAttachment

佐手、 提交于 2019-12-29 05:47:09
问题 I can create a multi-line NSAttributedString by using escaped new-line characters ( @"\n" ). With iOS 7, I can now embed a UIImage inside attributed strings (via NSTextAttachment ). I have noticed that whenever I set the attributedText of a UILabel to a multi-line attributed string with an embedded image, the number of lines actually displayed is inversely proportional to the height of the label. For example, when the height of the label is 80, two lines appear; when the height is around 100,