uilabel

UILabel won't update even on dispatch_async

て烟熏妆下的殇ゞ 提交于 2019-12-13 08:36:09
问题 Any reason why my label won't update? - (void)setLabel:(NSNotification*)notification { dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"setLabel"); [self.label setText:@"My Label"]; }); } I've also tried using performSelectorOnMainThread to no avail. Note that setLabel is appears on the log. Additional info: I also have two other functions which does the same thing but only with a different text. The two other functions doesn't have dispatch_async but they both work. Also, the

Multiple colors in a UILabel

蓝咒 提交于 2019-12-13 07:36:09
问题 I'm trying to set a UILabel with multiple colours in code. I've made a simple example: - (void)viewDidLoad { [super viewDidLoad]; static UIFont *font; font = [UIFont fontWithName:@"HelveticaNeue-Light" size:10]; NSArray *attributes = @[ @{ [UIColor redColor]: NSForegroundColorAttributeName, font: NSFontAttributeName }, @{[UIColor blueColor]: NSForegroundColorAttributeName, font: NSFontAttributeName}, @{[UIColor greenColor]: NSForegroundColorAttributeName, font: NSFontAttributeName} ]; NSArray

Organize and adjust the UILabel position per devices - Swift 3

旧街凉风 提交于 2019-12-13 07:26:56
问题 I have SQLite database file and UILabel, and I set text for label from database on the number of characters after convert String to Characters , and I added extension its name ( length ), its job counts the number of characters. My problem in this picture is : The UILabels are not organized in sizes and positions in per devices I want them to have their positions in the center of X-Axis Questions: 1) How to set the label into center and set spaces right and left of screen for labels (per

Resizing UILabel not quite working

做~自己de王妃 提交于 2019-12-13 06:25:45
问题 I'm resizing a table's cell and a UILabel . The label seems to be resized, but remains on one line. How to deal with this?! The label is set from the storyboard as: Line Breaks: Word Wrap; Autoshrink: Fixed Font Size; Lines: 0 CGRect textRect = [cell.sampleLabel.text boundingRectWithSize:boundingSize options:NSStringDrawingUsesLineFragmentOrigin attributes: @{NSFontAttributeName:cell.sampleLabel.font} context:nil]; NSLog(@"textRect height: %f", textRect.size.height); cell.sampleLabel.frame =

Reload TableViewCell's UILabels in dynamic table

穿精又带淫゛_ 提交于 2019-12-13 05:48:54
问题 I got app with UITableView. There is UILabel in each UITableViewCell. I add labels in this way: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //look at the upd } But when i try to reload data in this table with some other information, old infromation (old labels) dont disappear, but still on cells. It's look like this: ... How should i organized adding UILabels? UPD I correct code in this way: - (UITableViewCell *)tableView:

Animate UILabel resizing from center?

北城以北 提交于 2019-12-13 05:32:00
问题 I want to resize my label from center and animate that process. However, the only option I can use there is CGAffineTransformMakeScale with default anchor point of corresponding CALayer. [UIView animateWithDuration:0.5 animations:^{ self.title.transform = CGAffineTransformMakeScale(2.0,1.0); }]; But it squished the text inside. I considered this answer and it looks like the problem is solved in Swift. However, I can't modify only size part of the frame . How to approach this in Obj C? 回答1:

UILabel text color transparency with layer shadows in place?

点点圈 提交于 2019-12-13 05:29:41
问题 I have a UILabel to which I am attempting to apply a semi-transparent gradient as a color onto. For example, in my UILabel subclass I'm trying to set the gradient color this way: self.textColor = [UIColor colorWithPatternImage:someTransparentGradient]; While messing around with this, however, I discovered that a UILabel doesn't seem to be able to draw with transparency when layer shadows are in place . I attempted to set the text color to clear: self.textColor = [UIColor clearColor]; but the

How to draw a non-rectangle UILabel with paragraph truncation at the end?

五迷三道 提交于 2019-12-13 04:46:28
问题 I need to show a body of text similar to the one shown below and limited to the red non-rectangular area. Rob's answer to this question pretty much answers my question as well, but I also need to truncate at tail of the paragraph when the text is too long. Extra question: is it also possible to set minimum font size similar to UILabel? 回答1: Try using NSString::sizeWithFont:constrainedToSize method which is documented here. You can specify the fontsize and maximum size for the text. You can

Why is this label appearing unstyled?

一曲冷凌霜 提交于 2019-12-13 04:46:07
问题 I have, in starting to programmatically develop a screen, the following: NSInteger offset = 0; UIFont *font = [UIFont fontWithName:@"Scurlock" size:80]; UILabel *label = [[UILabel alloc] initWithFrame:(CGRectMake(20, 40 + offset, width, 20))]; [label setFont:font]; [label setText:@"Hello, world!"]; [self.view addSubview:label]; The "Hello, world!" does appear at the intended coordinates, but I have not found a way to change either the font family or font size. Scurlock is a TrueType font

iOS - Storing groups of UILabels into a NSMutableArray

有些话、适合烂在心里 提交于 2019-12-13 04:26:12
问题 I'm creating UILabel s dynamically in a for each loop. Every loop that is run creates 1-4 UILabels. What I want is that I put these UILabels into my NSMutableArray and being able later to easy retrieve the data. My original thought was to put these UILabels into a NSDictionary and use [dictGroupLabels setValue:uiLabel1 forKey:@"uiLabel1"] and then [dictGroupLabels setValue:uiLabel2 forKey:@"uiLabel2"] and so on. And then put this dictionary into my NSMutableArray for each loop. Later on I