uilabel

Resize UILabel correct on top of UIImageView

廉价感情. 提交于 2019-12-06 10:01:31
问题 My problem is as follows: I have on top of a UIImageView some labels. The image is a formular and the UILabel s represents the entries. If I rotate the device the image inside UIImageView gets resized with option "aspect fit". How can I achieve that the UILabel is also resized and aligned correct? The normal options for resizing aren't working as needed. The UIImageView is zoomable with minimumZoomScale and maximumZoomScale set. Thanks. 回答1: You can resize a UILabel proportionally using:

How to calculate the Width and Height of NSString on UILabel

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 09:49:28
I am working on a project to make the NSString on UILabel Width and Height dynamically. I tried with: NSString *text = [messageInfo objectForKey:@"compiled"]; writerNameLabel.numberOfLines = 0; writerNameLabel.textAlignment = UITextAlignmentRight; writerNameLabel.backgroundColor = [UIColor clearColor]; CGSize constraint = CGSizeMake(296,9999); CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap]; NSLog(@"sizewidth = %f, sizeheight = %f", size.width, size.height); NSLog(@"writerNameLabel.frame.size.width 1 -> %f

Center multiple UILabels on a line

你离开我真会死。 提交于 2019-12-06 09:18:33
I want to horizontally center multiple UILabels - as a group - on a line in Interface Builder. One the straight view controller i could not figure out how to do this. I read comments about place the UILabels in a View and then centering the view in the view controller. When I tried this, overtime I said to update frames in the interface builder, the View would be resized down to nothing. (i.e. its height and width would be set to 0 by IB). I need to know how to get this to work in interface builder. An example of a line containing multiple labels I want horizontally centered is below. The

Changing label's text in another view controller

不想你离开。 提交于 2019-12-06 08:35:20
问题 I have one view controller named FirstViewController, and a second named SecondViewController. I present second view controller with UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"mainController"]; [self presentViewController:controller animated:YES completion:nil]; In SecondViewController's .m, I want to change the text of a UILabel in FirstViewController. However, the label's text isn't updating. How would I make it so that the FirstViewController

How to set the colors in glowing effect of a UILabel?

青春壹個敷衍的年華 提交于 2019-12-06 08:08:55
问题 We can typically set fontColor of a UILabel by: label.textColor = self.someTextColor; and the shadow (glow) by: label.layer.shadowColor = self.someGlowColor; label.layer.shadowOffset = CGSizeMake(0.0, 0.0); label.layer.shadowRadius = 3.0; label.layer.shadowOpacity = 0.5; It'ok for simple shadow. However, how can I set the font color with some fancy glowing effect? For example: Provided A is the color at center, B is color at font boundary, and C the glow effect. How can I use iOS API to

Text padding on UILabel

偶尔善良 提交于 2019-12-06 07:59:41
Here, I am trying to have a label with some padding (left, right, top and bottom) around the text. This issue has related post on SOF and after reading a few of them, I tried using a solution proposed here : This is the code for my subclassing UILabel: import UIKit class LuxLabel: UILabel { //let padding: UIEdgeInsets var padding: UIEdgeInsets = UIEdgeInsets.zero { didSet { self.invalidateIntrinsicContentSize() } } // Create a new PaddingLabel instance programamtically with the desired insets required init(padding: UIEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)) { self

How to animate the textColor of a UILabel?

為{幸葍}努か 提交于 2019-12-06 07:59:05
Could you please tell me how to animate the textColor of a UILabel ? For example I would like to change the color from WHITE to RED, then come back to WHITE with a fade-in effect and repeat that about 3 times. I need this animation because my app gets real time data from the internet and when a value is changed I need to animate this text value to tell the user that it has changed . Thank you so much. The reason that textColor is not animatable is that UILabel uses a regular CALayer instead of a CATextLayer. To make textColor animatable (as well as text, font, etc.) we can subclass UILabel and

UILabel in header of UITableView in objective c

空扰寡人 提交于 2019-12-06 07:59:01
I am making an iPad app where in I have a grouped TableView with headers for the sections. i want to add four label in header of tableview text of four label's are "company", "current", "prev close" ,"change" or instead of adding four labels in header, i want to add four text "company", "current", "prev close" ,"change" What should I do? Please Help and Suggest. Thanks. There is a delegate method of UITableView for custom view of Header - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0,0

Orthographic hyphenation word in IOS

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 06:00:37
问题 Is there a way of orthographic hyphenation word? Something like this: NSStiring *string = @"In June 2010 at the World Wide Developers Conference, Apple announced version 4 of Xcode during the Developer Tools State of the Union address."; UILabel *label = [[UILabel alloc] init]; label.text = string; And if frame UILabel will be narrow, get next: In June 2010 at the World Wide Developers Con- ference, Apple announced ver- sion 4 of Xcode during the Devel- oper Tools State of the Union ad- dress

Dynamic UILabel content inside of a UIScrollView

情到浓时终转凉″ 提交于 2019-12-06 05:59:20
问题 I've got a UILabel (amongst other controls) stored within a UIScrollView. I want to dynamically populate the UILabel so that it automatically expands its height to fit its contents. I'm just wondering what the best practice is with regards to resizing the UILabel while also ensuring that its parent UIScrollView will also expand its scrollable area. I've tried to set the UILabel's # of Lines to 0, which I've read should automatically expand the UILabel to fit its contents, but I'm not having