uilabel

Stretching and kerning type, not working in Storyboard with @IBDesignable

醉酒当歌 提交于 2019-12-18 09:07:08
问题 Here is a IBLabel which tracks / stretches the font. It works perfectly in the build. But the change doesn't show live in Storyboard. // UILabel, but you can set // the tracking (that's the overall amount of space between all letters) // and streching (actually squeeze or stretch the letters horizontally) // Note: it's very common that typographers need you to adjust these. import UIKit @IBDesignable class StyledLabel: UILabel { @IBInspectable var tracking:CGFloat = 0.8 // values between

UITableViewCell textColor will not change with userInteractionEnabled = NO

北城余情 提交于 2019-12-18 08:54:09
问题 I am trying to simply change the color of my UILabel using the textColor property and it will not work when userInteraction is disabled, this does not make any sense, there is nothing in the documentation that mentions that at all. But that is what is happening if I remove that line the color does change, but I do not want user interaction. UITableViewCellStyleValue1 A style for a cell with a label on the left side of the cell with left-aligned and black text ; on the right side is a label

How to adjust a label size to fit the length of the text

两盒软妹~` 提交于 2019-12-18 07:33:28
问题 I have searched the solution to this in the past QAs, but could not find the right one. Does anyone know how to adjust a UILabel size dynamically to fit the text length? I have uploaded the screen shot of what I don't want(1st line) and what I want(2nd line). I'd appreciate any clues, advice or code sample. Thank you. 回答1: What you are searching is the UILabel method sizeToFit I can try to explain to you, but the best answer to know how to work with UILabel is that: https://stackoverflow.com

auto adjust custom UITableViewCell and Label in it to the text

橙三吉。 提交于 2019-12-18 07:17:26
问题 I have a custom UITableViewCell that only has one Label in it. I also set number of lines in Interface Builder to 0 as I read on StackOverflow. import UIKit class CommonListViewCell: UITableViewCell { @IBOutlet var background: UIView! @IBOutlet var titleLabel: UILabel! override func awakeFromNib() { super.awakeFromNib() // Initialization code titleLabel.font = UIFont(name: "roboto", size: titleLabel.font.pointSize) NSLog("CommonListViewCell font changed") } } Here's the view controller's part

Change NSTextField font size to fit

杀马特。学长 韩版系。学妹 提交于 2019-12-18 06:22:19
问题 Is there anything like the UILabel's adjustsFontSizeToFitWidth that can be used with a NSTextField? 回答1: In short: no. You have to do some brute force work to determine a string's -sizeWithAttributes: -boundingRectWithSize:options:attributes: with a given font size (set as an NSFont for NSFontAttributeName). I'd start with a standard system font size and work down or up from there, depending on whether it's smaller or larger than the desired rectangle. 回答2: Swift 4 solution: It will resize

Xcode6, iOS8 and (void)layoutSubviews

爷,独闯天下 提交于 2019-12-18 04:52:47
问题 I have custom UILabel which works fine on iOS6 and iOS7. But on iOS8 this label's (void)layoutSubviews method never get called. I create this label with initWithFrame, so this method should be called - and it's called on another iOS versions. What happens with autoLayout system in iOS8? 回答1: I just want to add this answer because the question title may lead a lot of ppl here with similar issues (like me). With iOS 8 to 8.0.2 LayoutSubviews calls are unreliable. They may not be called ever or

Scrolling UILabel like a marquee in a subview

ぐ巨炮叔叔 提交于 2019-12-18 04:23:38
问题 I have a UILabel in the main view with text - "Very Very long text" . The proper width to this would be 142, but i've shortened it to 55. Basically I want to implement a marquee type scroll, so I wrote code to add it onto a subview and animate it within the bounds of that view. CODE -- CGRect tempLblFrame = _lblLongText.frame; UIView *lblView = [[UIView alloc] initWithFrame:tempLblFrame]; //Add label to UIView at 0,0 wrt to new UIView tempLblFrame.origin.x = 0; tempLblFrame.origin.y = 0; [

Calculating number of lines of dynamic UILabel (iOS7)

有些话、适合烂在心里 提交于 2019-12-18 04:09:23
问题 There are many solutions to this questions arround but couldn't find non-deprecated one. I have an UILabel with mode WordWrap and fixed width of, let's say 250. Lines are set to 0. Here is what I tried: UILabel *contentLabel = (UILabel*)[contentView viewWithTag:10]; CGSize size = [contentLabel.text sizeWithFont:contentLabel.font forWidth:contentLabel.frame.size.width lineBreakMode:NSLineBreakByWordWrapping]; NSLog(@"Label's height is: %d", size.height); The output of height param is always 20

Two lines of text in a UISegmentedControl

雨燕双飞 提交于 2019-12-18 01:13:09
问题 Try as I might, I can't solve a UISegmentedControl bug for an iOS7 iPhone app. When I create the segmented control, I use this code: NSArray *segmentedControlItemArray = [NSArray arrayWithObjects: @"Nominal:\n27 inch", @"Actual:\n700c x 23mm", @"Actual:\n700c x 20mm", nil]; _wheelDiameterSegmentedControl = [[UISegmentedControl alloc] initWithItems:segmentedControlItemArray]; _wheelDiameterSegmentedControl.frame = CGRectMake(0, 102, 290, 50); _wheelDiameterSegmentedControl.selectedSegmentIndex

How to make an underlined text in UILabel?

扶醉桌前 提交于 2019-12-17 23:09:52
问题 How can I make an underlined text in UILabel ? I had tried by making a UILabel with height 0.5f and place it under the text. This line label is not visible when I am running my app in iPhone 4.3 and iPhone 4.3 simulator , but it is visible in iPhone 5.0 simulator onwards. Why? How can I do this? 回答1: Objective-C iOS 6.0 > version UILabel supports NSAttributedString NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:@"Hello Good Morning"];