uilabel

UILabel sizeThatFits not working

我们两清 提交于 2019-12-10 15:16:59
问题 I'm trying to calculate the height for a UITableViewCell so I've defined a class method that looks like this + (CGFloat)heightWithText:(NSString *)text { SizingLabel.text = text; [SizingLabel sizeThatFits:CGSizeMake(LABEL_WIDTH, CGFLOAT_MAX)]; return (TOP_MARGIN + SizingLabel.frame.size.height + BOTTOM_MARGIN); } I've defined SizingLabel like this: + (void)initialize { SizingLabel = [[UILabel alloc] initWithFrame:CGRectZero]; SizingLabel.numberOfLines = 0; SizingLabel.lineBreakMode =

Word Wrap not working for UILabel

别说谁变了你拦得住时间么 提交于 2019-12-10 14:27:04
问题 Using autolayout I can't override my label in code. I've set the labels attributes in IB: Lines = 0, LineBreaks = Word Wrap, but I have my height set to a single line because due to what cell is selected determines what text goes in the label. So sometimes the label will only have one line. In my viewDidLoad: myLabel.text = @”blah, blah, blah….”; [myLabel setLineBreakMode:NSLineBreakByWordWrapping]; myLabel.numberOfLines = 0; //have tried 1 but didn’t help [myLabel sizeToFit]; This works on

SubClassing UILabel

拟墨画扇 提交于 2019-12-10 13:48:22
问题 I read in this same site how to inset and UILabel (subclass UILabel and override the required methods). Before adding it to my app I decided to test it out in a standalone test app. Code is shown below. Here's MyUILabel.h #import <UIKit/UIKit.h> @interface MyUILabel : UILabel @end Here's MyUILabel.m #import "MyUILabel.h" #import <QuartzCore/QuartzCore.h> @implementation MyUILabel - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code }

Is it possible to set different font in One UIlabel?

我与影子孤独终老i 提交于 2019-12-10 13:33:57
问题 I have a string like "This is a good apple." to display on my UIlabel. I would like to set the word "good" with different font. Just look like "This is a good apple." 回答1: Take a look at NSAttributedString... Use OHAttributedLabel draw NSAttributedString because UILabel,UITextView doesnot support NSAttributedString... PS: if you plan to distribute an iOS6 or newer application, as UILabel now support NSAttributedString, you should use UILabel directly instead of OHAttributedLabel as it is now

UILabel min font size shadow issue

99封情书 提交于 2019-12-10 12:47:20
问题 I have an issue when setting minimum font size on my UILabels . As you can see the shadow isn't following along with the font size. It's supposed to be just 1 px heigh. My label: My settings: 回答1: Turn off "Tighten Letter Spacing". There seems to be a bug with shadows, auto shrinking, and auto tightening. 回答2: Set the shadow.offset programmatically based on font size. 回答3: You have set the Value 12 Below the Minimum Font Size you can't set this value its Too large pass it like 0.5 or 0.8

UISegmentedControl delegate/Touch Events

喜夏-厌秋 提交于 2019-12-10 12:30:32
问题 I have a UISegmentedControl that has six segments, I want them to call a method when the value changes, but also when each segment gets a UIControlEventTouchDragIn because I want a UILabel to show up with it's name when the person is trying to select something on it and drags their finger across the control, but the segmented control does not sen this call even when I drag into the thing. Please help. Maybe I need to create UIButtons over the control that call methods upon a drag in, but call

I'm having trouble dynamically updating a UILabel in one controller from another. It needs to correspond to a checkbox being checked in objective-c

半世苍凉 提交于 2019-12-10 12:26:43
问题 Working on a shopping store app. I've been going in circles for the past week and a half trying to figure out how to correctly do this. The problem lies in a UILabel that needs to be dynamically updated with text that corresponds to checked checkboxes. It also needs to know whether to apply selection when apply button has been tapped or return previous selection if customer decided to change their mind and not tap apply. This is where I'm running into issue. I refer to 3 controllers as image

NSAttributeString Height seems align wrong when use both image and text

爱⌒轻易说出口 提交于 2019-12-10 11:48:09
问题 I have a uilabel in tableviewcell ,and the label use NSAttributeString to support both image and text. But I found when the label contains image or text only , the height of label is correct ,but when label contains image and text both ,the height seems not correct .the row height seems little more big than the actual height need and if there is text or images only ,the height is right and I was using my Own subclass from NSTextAttachment to construct image and the attachment code is like

How to add function-call (not hyperlink) to part of an NSAttributedString in a UILabel?

允我心安 提交于 2019-12-10 11:39:53
问题 I need to add some tapGestures to some part of a text, thats in a UILabel. It seems to be able to make a hyperlink - so I guess its possible to make a functioncall as well, but I'm just not sure how to do it. Heres my code: let regularFont = UIFont(name: Constants.robotoRegular, size: 13)! let att1 = [NSFontAttributeName: regularFont] let turqoiseFont = UIFont(name: Constants.robotoBold, size: 13)! let att2 = [NSFontAttributeName: turqoiseFont] let attString1 = NSMutableAttributedString

ios - Objective-c only the first cell of UITableView doesnt show the label I added

£可爱£侵袭症+ 提交于 2019-12-10 11:17:57
问题 I'm trying to add number from 1 to 9 from plist to each cell in UITableView. However the first view shows nothing and 1 is shown in the second cell, 2 is shown in the third cell and so on. I did some tests by adding NSLog(@"test"); inside if(cell==nil) but only 7 "test" is printed while there are 9 cells.. does that mean codes inside if(cell==nil) do not executed for the first and last cell? Anybody care to solve this problem? :( // Customize the appearance of table view cells. -