uilabel

How do I place a slider value in label?

て烟熏妆下的殇ゞ 提交于 2019-12-23 03:00:30
问题 I am quite new to Xcode and I am having trouble placing the value of a slider in a label when the slider is value is changed. Here is my code: Header file: @interface ViewTwoViewController : UIViewController { IBOutlet UISlider *slider; IBOutlet UILabel *sliderLabel; } -(IBAction)sliderValue:(id)sender; and here is my m file: -(IBAction)sliderValue:(UISlider *)sender { sliderLabel.text = [NSString stringWithFormat:@"%g", slider.value]; } I am not 100% sure why the value isn't updating? I am

How do I center embedded fonts vertically within UILabels?

浪尽此生 提交于 2019-12-23 01:13:33
问题 In a previous question: Embedded fonts in iOS: why are they not centered correctly on the y axis? it was noted that embedded fonts were not being centered vertically in iOS controls. A solution was proposed there, but that solution only works with buttons. How can we properly center embedded fonts within UILabels? 回答1: I've had a problem with a custom font in iOS that had very tall glyphs so they were getting clipped by the label. Ended creating my own label subclass with self created

How do I center embedded fonts vertically within UILabels?

戏子无情 提交于 2019-12-23 01:13:32
问题 In a previous question: Embedded fonts in iOS: why are they not centered correctly on the y axis? it was noted that embedded fonts were not being centered vertically in iOS controls. A solution was proposed there, but that solution only works with buttons. How can we properly center embedded fonts within UILabels? 回答1: I've had a problem with a custom font in iOS that had very tall glyphs so they were getting clipped by the label. Ended creating my own label subclass with self created

[转]关于UILabel UITextView UIWebView 行间距 文字排版

半世苍凉 提交于 2019-12-23 00:11:42
有时候可用 UIWebView 代替 UITextView,解决行间距问题 2011-12-10 — Unmi 我们在使用 UILabel 或是 UITextView 时,如果文字出现了换行,目前我还不知道如何去控制行间距,固定的 Label 文字 可以折成两个 Label 上下显示,但是对应大段显示的段落要多行显示时该如何呢,多行单独控制就变得不现实了。 由于 UILabel 或 UITextView 并不提供对行间距 line-height 的设置,要达成所愿指定行间距的方法,我可以想到三种方式: 1. 自定义相应的控件,在控件内部方法中去做文章,未实践,可能是个好方法 2. 修改字体,由于默认行间距是由字体本身特性决定的,所以可以修改字体来满足有限的需求,不是很现实 3. 用 UIWebView 来代替 UITextView,这是本文的思想 先看个图片,看看在使用某些字体时失控的行间距是什么样的效果: 说明:上图左边是用 UITextView 来显示一段文字,由于行间距不可控,不是我们想要的。右边就是用 UIWebView 来显示的同一段文它,它的行间距我们可以随意控制。 思才过程是这样的,对于 UITextView 多行文字显示时行间距不能直接用代码来设置,特别是对于某些字体来说行间距确有些夸张。然后首先想到的解决方式是创建自己的 UITextView 子类

Center multiple UILabels on a line

故事扮演 提交于 2019-12-22 23:08:16
问题 I want to horizontally center multiple UILabels - as a group - on a line in Interface Builder. One the straight view controller i could not figure out how to do this. I read comments about place the UILabels in a View and then centering the view in the view controller. When I tried this, overtime I said to update frames in the interface builder, the View would be resized down to nothing. (i.e. its height and width would be set to 0 by IB). I need to know how to get this to work in interface

Center multiple UILabels on a line

て烟熏妆下的殇ゞ 提交于 2019-12-22 23:05:22
问题 I want to horizontally center multiple UILabels - as a group - on a line in Interface Builder. One the straight view controller i could not figure out how to do this. I read comments about place the UILabels in a View and then centering the view in the view controller. When I tried this, overtime I said to update frames in the interface builder, the View would be resized down to nothing. (i.e. its height and width would be set to 0 by IB). I need to know how to get this to work in interface

Center multiple UILabels on a line

核能气质少年 提交于 2019-12-22 23:05:01
问题 I want to horizontally center multiple UILabels - as a group - on a line in Interface Builder. One the straight view controller i could not figure out how to do this. I read comments about place the UILabels in a View and then centering the view in the view controller. When I tried this, overtime I said to update frames in the interface builder, the View would be resized down to nothing. (i.e. its height and width would be set to 0 by IB). I need to know how to get this to work in interface

fatal error when prepared to segue to view controller

青春壹個敷衍的年華 提交于 2019-12-22 18:47:09
问题 I'm currently getting a fatal error unexpectedly found nil while unwrapping an optional value at destViewController.titleLabel.text = "Testing Segue". How do I fixed it since it getting me a error when it segue to SecondViewController? How do I avoid getting nil at titleLabel.text? class ViewController: UIViewController { @IBAction func action(sender: AnyObject) { let alertController: UIAlertController = UIAlertController (title: "Next Page", message: "", preferredStyle: .Alert) let yesAction

UILabel Dynamic Font size keep breaking

被刻印的时光 ゝ 提交于 2019-12-22 16:40:12
问题 I Have CollectionViewCell that has only UILabel(Same bounds as cell). I'm fetching array of fontNames as the CollectionView DataSource : func printFonts() { let fontFamilyNames = UIFont.familyNames() for familyName in fontFamilyNames { let names = UIFont.fontNamesForFamilyName(familyName as! String) fontNames.append(familyName as! String) } } I'm trying to display this font names in one line inside the UILabel , it works in some of the cases but in some not, and i have not idea why. this is

NSLineBreakMode enum and backwards compatibility

房东的猫 提交于 2019-12-22 14:08:43
问题 I need my app to support iOS 5+. Since prior iOS 6 the enum lineBreakMode for line break mode in UILabel is of type UILineBreakMode, and it is of type NSLineBreakMode for iOS 6+, what should be the best (or more correct) way to check the iOS version currently running to determine the type to be used? Is it correct to directly do something like [[UIDevice currentDevice] systemVersion] , or is there a better way? Thanks! 回答1: You do not need to check the iOS version at runtime, the enum values