uilabel

Updating UITableViewCell subview's frame has no effect

孤街醉人 提交于 2019-12-23 09:41:02
问题 I have a custom (subclassed) UITableViewCell which contains a few UILabels, a UIButton, and a NSBlock as properties. This subclass is called ExploreCell . Two of the properties are UILabels and are named waitLabel and lastUpdateLabel respectively. When the contents of lastUpdateLabel is nil or is is blank i.e. @"" , I need to move the waitLabel vertically down (on the Y axis) 10 pixels. I am doing this by checking some objects in an NSDictionary as shown in the following code which I have put

Why isn't my UILabel being changed?

♀尐吖头ヾ 提交于 2019-12-23 09:40:14
问题 Why isn't my UILabel being changed? I am using the following code, and nothing is happening: - (void)awakeFromNib { percentCorrect.adjustsFontSizeToFitWidth; percentCorrect.numberOfLines = 3; percentCorrect.minimumFontSize = 100; } Here is my Implemintation code: - (void) updateScore { double percentScore = 100.0 * varRight / (varWrong + varRight); percentCorrect.text = [NSString stringWithFormat:@"%.2f%%", percentScore]; } - (void)viewDidLoad { percentCorrect.adjustsFontSizeToFitWidth = YES;

Fade out end of text label strings that don't fit (instead of truncate)

走远了吗. 提交于 2019-12-23 09:01:49
问题 I'm not sure if "fade out" is the correct term to use, as it seems to refer to the animation effect a lot, but what I'd like to achieve can be seen in the address bar of the iPhone Safari app. When a URL is too long to display, the end of the string "faded out" rather than truncated with "...". I thought this could be easily done by changing the Line Breaks setting from "Truncate Tail" to "Clip" in the XIB file and then using an image with transparency to create the effect. But setting to

Setting vertical align of truncated tails for NSAttributedString with NSTextAttachment

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 07:45:38
问题 I'm using the following code to generate a NSAttributedString for UILabel in iOS 8. // a long long Chinese title NSString *title = @"这是一个很长很长很长很长很长很长的中文标题"; // setup icon attachment NSTextAttachment *iconAttachment = [[NSTextAttachment alloc] init]; iconAttachment.image = [UIImage imageNamed:imageName]; iconAttachment.bounds = bounds; NSAttributedString *ycardImageString = [NSAttributedString attributedStringWithAttachment:iconAttachment]; // setup attributed text NSMutableAttributedString

Placing UILabels next to each other programmatically [closed]

二次信任 提交于 2019-12-23 05:26:05
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I have three UILabels of varying widths that I'd like to line up next to each other. How do I get update the frame's X value? Here's what I have: UILabel

Change a UILabel's text from another class

血红的双手。 提交于 2019-12-23 05:04:37
问题 I have a view controller and a class (I am using storyboards). How can I change the text of a UILabel (in the view controller) from the class? I have tried this, but to no avail: ViewController *mainView = [[ViewController alloc] init]; [mainView view]; [mainView.progressBar setProgress:integer animated:YES]; NSLog(@"Updated Progress Bar"); NSString *progressLabelText = [NSString stringWithFormat:@"%@ out of %i followers", userString, [self.followers count]]; [mainView.progressLabel setText

Line up three UILabels next to each other and each label can be multiline

一曲冷凌霜 提交于 2019-12-23 04:52:10
问题 I'am working on a project where I need to line up 3 UILabels next to each other. Let me explain it with an example. I have for example the following sentence. "Tim Moore commented on the little bear story" Now my three UILabels going to contain: LABEL 1 --> Tim Moore LABEL 2 --> commented on LABEL 3 --> the little bear story another example: Dave Smits likes the status "We and only we can me a knew future and only we nobody else can make changes, so don't stop now !" LABEL 1 --> Dave Smits

How to resize UILabels to fit content?

∥☆過路亽.° 提交于 2019-12-23 04:45:45
问题 My program currently has thirty UILabels that may contain numbers between one and three digits. I want my UILabels to expand and shrink horizontally as the numbers within them change size. At the moment the text is shrinking and the UILabels size remains the same. If this can be done just using the xib file this would be preferable to doing so programmatically but if this isn't possible either would be great. Thanks 回答1: After setting the text of the label, call sizeToFit on the label. This

Setting attributed label as navigation title

人盡茶涼 提交于 2019-12-23 04:30:45
问题 I am working on IOS using swift 4. I have to make the Navigation controller, with the center Aligned App title with Image at its left. But I am not getting how to attach image to its left. The attributed Image always goes to its right. For this I am appending the string twice. below is the code //Get image and set it's size let image = UIImage(named: "user2") let newSize = CGSize(width: 30, height: 30) //Resize image UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0) image?.draw(in:

iPhone: How to make a tip balloon programmatically?

心不动则不痛 提交于 2019-12-23 03:19:11
问题 Please provide the code to make a tip balloon programmatically, like Grindr has. I want it to be sized automatically, based on the text & font-size. And, I want to be able to change the location of the arrow. If it's on an end, it should be a right triangle. Otherwise, it should be an eqilateral triangle. 回答1: // AppDelegate.h @interface AppDelegate : NSObject <UIApplicationDelegate> { } @property (nonatomic, retain) UIWindow *window; @end // AppDelegate.m #import "AppDelegate.h" #import