uilabel

UILable numberoflines and font size automatically set during zoom in out time

爷,独闯天下 提交于 2019-12-24 17:04:52
问题 My requires is as below. i have a added UILable inside UIView width & height is 30 . i have set UIPinchGestureRecognizer to that UIView . Pinch in out functionality is working fine with UIView. But my i want that when i zoom in UILable font size and numberOfLine automatically set in that UIView . So at initial UILable not visible in View. When i Zoom in that time UILable get the are to display text so than UILable will be visible (ex. This time in 3 line). If i increase the Zoom level than

Why is my UILabel variable always nil?

一笑奈何 提交于 2019-12-24 15:31:44
问题 I am simply trying to connect a variable with a UILabel in Swift. I have looked at many tutorials but I keep getting errors. The main cause seems to be that @IBOutlet weak var str = UILabel! is always nil. When I try to assign a value to it, the console prints a fatal error: unexpectedly found nil while unwrapping an Optional value and inside the coding interface, the line self.stringLabel.text = self.string is highlighted with the error Thread 1: EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP

Nil when unwrapping an Optional Value in didBecomeActive()

扶醉桌前 提交于 2019-12-24 13:38:33
问题 I'm incredibly confused with the following scenario in my UIViewController : I have the following @IBOutlet which has a referencing outlet in my Storyboard. class MainViewController: UIViewController { @IBOutlet weak var warningLabel: UILabel! } I then have this in my AppDelegate : var mainViewController: BLEMainViewController? func applicationDidBecomeActive(application: UIApplication) { let mainViewController: MainViewController = mainStoryboard.instantiateViewControllerWithIdentifier(

UITableview items becomes bold after scrolling up

一笑奈何 提交于 2019-12-24 13:38:24
问题 Ok maybe I am being too picky. Apologies in advance if you cannot see it, but in the second pic, the item on the row is pixellated a bit, or as if a word was placed on top of a word. This only happens after I scroll up on the tableview, otherwise, it is similar to the first image. First pic: Second pic (you can see the difference in the font here): it's a bit more bold and unrefined once I scroll up. I frankly have no idea why. The tableview is being loaded normally. Any help, hunch, or

Have half a UILabel text bold and half not?

浪尽此生 提交于 2019-12-24 11:40:18
问题 I want half of my UILabel 's text to be bold and half to not be bold. How can I do this? 回答1: NSAttributedString allows for specification of formatting within a string, but sadly, UIKit does not yet do anything with this. However, there are a few open-source implementations that do. Check out OHAttributedLabel. 回答2: You can't do this easily unless you subclass UILabel and mess with the subviews. Better to use two UILabels instead. Found another thread about it here. 回答3: UILabel has

iPhone Character Spacing

落花浮王杯 提交于 2019-12-24 10:07:19
问题 Is there a way to add character spacing in UILabel? I found some examples like: How to change an UILabel/UIFont's letter spacing? But it's hard to believe that there isn't a easier way. 回答1: There is no other to achieve what you want than doing custom Quartz drawing, UILabel is not flexible enough. However, other people have taken on the challenge, there is for example OHAttributedLabel which allows you to set an NSAttributedString as the label's text. Try the NSKernAttributeName , it

How to change label color inside table cell with swift 3?

試著忘記壹切 提交于 2019-12-24 09:38:03
问题 I put label inside table cell. I changed the text color into "White" in Attributes inspector. I also changed the label background color into "Green". When I run the app, the text color does not change into white color but background changed to green. I also put the code. cell.lblName.textColor = UIColor.white I declare this @IBOutlet weak var lblAllowAutoRenew: UILabel! in MediaPackListCell.swift file. In TableView.swift , func tableView(_ tableView: UITableView, cellForRowAt indexPath:

Random Text Sent to UILabel

你说的曾经没有我的故事 提交于 2019-12-24 09:28:34
问题 I'm trying to create an array that holds x amount of literal strings that will randomly send one to a UILabel after you hit a UIButton. How should I structure the .h and .m files to do this? Also, what is the best way to generate the random number I need? 回答1: You would get a random integer for the index, and then just pass the object you get to the UILabel's text property, eg: //assuming you already have an NSArray of strings myLabel.text = [arrayOfString objectAtIndex:arc4random() %

How do I change the font size according to screen size

梦想的初衷 提交于 2019-12-24 08:12:36
问题 I have added min font size to label but the font is not changing according to the screen size. I thought setting min font size and using autolayout is to scale the label height is enough. But its not happening. 回答1: Use minimum font scale instead of minimum font size. Minimum font size was deprecated in IOS 6. In the image although mine says fixed here you can change that and then set the scale factor. To vary by size of the screen you can do some of that with interface builder. See image.

How to manage text glyph boundary

左心房为你撑大大i 提交于 2019-12-24 08:07:54
问题 Suppose I have a clock app, and I want to label the hours with characters that could be in an arbitrary character set/font. I'd like to frame the character in a frame and fill it as much as possible. How can I do that? If I use a UILabel , space gets inserted around the glyph. Here are examples showing two labels, both with the same font but with different characters. The Hebrew numerals all seem shorter than the Arabic numerals. Is there a way to determine the size of the glyphs or somehow