uilabel

Find UILabel bottom position so a second UILabel can be created below

匆匆过客 提交于 2019-12-11 05:38:04
问题 I have a new article that I am creating. A UILabel is being added for the article title. The title text sometimes might be one, two or three lines of text. I then need to create a UILabel below the title. I am having trouble positioning the date UILabel since the title has a dynamic height. Is there a calculation to get the bottom position of my UILabel 's frame? Note: I am using siteToFit to make sure the UILabel 's frame fits. // Text UILabel *title = [[UILabel alloc] initWithFrame

NSLabel Autoshrink with top constraints

偶尔善良 提交于 2019-12-11 05:33:05
问题 I try to figure out autoshrink option in UILabel with regarding top constraint. I have UIView and three labels. One of them has autoshrink option on. It has constraint to be centered, and has Trailing and Top constraint which should shrink label when changing size of UIView. If I make UIVIew thinner, font size is decreased, but if I change height of UIView font is not changed. Constraints on UILabels : Align Center X to Superview Align Center Y to Superview Trailing Space to Superview >= 50

Show UIPickerView on label click

☆樱花仙子☆ 提交于 2019-12-11 04:26:31
问题 I use UIPickerView to select data for label: class BookingOptionsViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { @IBOutlet weak var lblProfile: UILabel! var data = ["1", "2", "3"] var picker = UIPickerView() override func viewDidLoad() { super.viewDidLoad() picker.delegate = self picker.dataSource = self let tap = UITapGestureRecognizer(target: self, action: #selector(tap(gestureReconizer:))) lblProfile.addGestureRecognizer(tap) lblProfile

Adding a UILabel's layer to another layer (Separate UIView)

ⅰ亾dé卋堺 提交于 2019-12-11 04:23:48
问题 I'm trying to understand why I can't add a UILabel's layer as a sublayer to another layer in a separate UIView object. - (void)addNumber:(NSInteger)number toLayer:(CALayer *)layer { UILabel *numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds))]; [numberLabel setFont:[UIFont boldSystemFontOfSize:12]]; [numberLabel setText:[NSString stringWithFormat:@"%d", number]]; /* if I change the BackgroundColor to an opaque color it renders

how can I set substring of a NSString as bold in UILabel [duplicate]

久未见 提交于 2019-12-11 04:22:23
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Bold & Non-Bold Text In A Single UILabel? I want to know that how can I set substring of a NSString as bold in UILabel ? for example : I have a string in UILabel say, *Apply to a bill of $16 or more and I want to make " $16 " bold . Thanks.... 回答1: Simply use TTTAttributedLabel It's perfect for your purpose. 回答2: You could also UIWebView for displaying rich content in iPhone. Display Rich Text Using a UIWebView

How do I toggle hidden of a label while a button is pressed?

我是研究僧i 提交于 2019-12-11 03:52:43
问题 I am trying to figure out how to only display a label while a button is pressed in OS. I know how to operate the touch events but I am not sure how to incorporate the UILongPressGestureRecognizer into this. 回答1: The UIButton class, as well as lots of other UIControl subclasses can have numerous actions hooked up to them. When we are hooking up an action from interface builder to our source code file, if we open the "Event" drop down, we're presented with a long list of options: In almost

Display multiple lines in a Table view's cell - IOS

谁都会走 提交于 2019-12-11 03:24:01
问题 i want to display multiple lines in a Table's cell view for an IOS app that i'm working on. To be precise, i have a table view which will be populated with the JSON data that is returned from server, in here if the status returned is 0 or 2 (Status is one of the JSON object that is being returned for a profile) i have to display an error message that is of 5-6 lines. Table's cell view is customized to display 2 UILabel's and obviously the height of this cell is small enough to display 2

How can I call an IBAction in the viewDidLoad?

試著忘記壹切 提交于 2019-12-11 03:19:15
问题 I have a simple slider app. When the slider is changed, the new value is displayed in a UILabel. That works great! When that view is loaded though the label is blank. I want the sliderValue.text to be equal to the default slider value. Here is my code right now (along with my previous attempt): -(IBAction)sliderValue:(UISlider *)sender { sliderLabel.text = [NSString stringWithFormat:@"%g", roundf(slider.value)]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after

Setting UILabel background color causes app to crash

可紊 提交于 2019-12-11 03:18:56
问题 I have the following code: UIImageView *photo = [[[UIImageView alloc] initWithFrame:CGRectMake(title_bar.titleView.frame.origin.x+130, title_bar.titleView.frame.origin.y-12, 22.0, 22.0)] autorelease]; UIImage *theImage = [UIImage imageNamed:@"question mark icon"]; photo.image = theImage; UIView *new_view = [[UIView alloc] init]; [new_view addSubview:photo]; UILabel *new_label = [[UILabel alloc] initWithFrame:CGRectMake(title_bar.titleView.frame.origin.x-145, title_bar.titleView.frame.origin.y

How to insert UILabel after UITextField in UIAlertController

别等时光非礼了梦想. 提交于 2019-12-11 03:17:23
问题 I have a UIAlertController of .alert style with message text. I have inserted a UITextFiled in it with addTextField(.... and now I want a string of text below it. I assume I need a UILabel but how do I insert it? 回答1: A UIAlertController sub-classes from UIViewController . Because of this, a UIAlertController contains a view which can be modified. So, to add a label to the alert, you could do this: let label = UILabel(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) label.text = "Text" alert