uilabel

iOS: UILabel dynamic height using sizeWithFont:constrainedToSize:lineBreakMode: not working

我的梦境 提交于 2019-12-09 13:24:39
问题 I am trying to give my UILabel dynamic height so that my layout of other labels looks correct in both landscape and portrait. In portrait, my text wraps to the second line, in landscape it does not. So, when using sizeWithFont:constrainedToSize:lineBreakMode: I get the same height when rotating both ways, when I had assumed it would be a larger number when the text was 2 lines. How can I get the height of my UILabel when it has two lines of text or more (portrait) and get the new height which

Centering a label in a UIView

ⅰ亾dé卋堺 提交于 2019-12-09 11:36:44
问题 What's the best way to center a label in a UIView ? If you do something such as UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(view.frame.origin.x / 2, view.frame.origin.y / 2, 50.0, 50.0)]; Then you're setting the origin point of the label to the center of the view. The best bet would be to set the center of the view to that point using the center property. So I tried using the following code: UIView *aView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen]

swift输入验证码提示框

左心房为你撑大大i 提交于 2019-12-09 10:31:26
// // XCSurePayV.swift // zjfae // // Created by apple on 16/4/19. // Copyright © 2016 年 onight. All rights reserved. // import UIKit class XCSurePayV: UIView { // var showView : UIView? override init (frame: CGRect ) { super . init (frame: frame) self . addSubview ( bgView ) self . addSubview ( showView ) showView . addSubview ( payLab ) showView . addSubview ( tishiTitle ) showView . addSubview ( codeTF ) showView . addSubview ( cancelBtn ) showView . addSubview ( sureBtn ) showView . addSubview ( line1 ) showView . addSubview ( line2 ) showView . addSubview ( line3 ) bgView .

iPhone/iPad UIButton TitleLabel text not appearing

白昼怎懂夜的黑 提交于 2019-12-09 04:30:32
问题 I created a grid of buttons. The following code creates the buttons and displays them, but there is no text on the button. Is there a setting I am missing? (Obj-C replies are fine, I'm bi-lingual) RectangleF frame = new RectangleF (X + 3, Y + 3, cellWidth - 2, cellHeight - 2); UIButton button = new UIButton (frame); button.TitleLabel.Text = "Baha'i"; button.TitleLabel.Font = UIFont.FromName ("Helvetica-Bold", 15); button.TitleLabel.TextColor = UIColor.Black; button.TitleLabel.Frame = frame;

Can we Add Tap Gesture to UILabel?

 ̄綄美尐妖づ 提交于 2019-12-09 03:58:50
问题 I have added Label in the UIView and created its outlet, then with the help of UITapGestureRecognizer i have added the functionality,but when i tap or click in the label. Label text does not changes. I searched for the similar question and i got the answer also its what I've written but still the label text is not changing. Code written in Swift 3.0. Here's the code i have written - import UIKit class testingViewController: UIViewController { @IBOutlet weak var testLabel: UILabel! override

UITableViewCell color issues with custom table view background

做~自己de王妃 提交于 2019-12-08 21:47:42
问题 I have a UITableView with a custom background image set like this: self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"mybg.png"]]; The background appears fine, but my UITableViewCells (default cells, not custom) have some sort of weird tint to them, and the UILabel containing the "New Project" text also seems to have some sort of background behind it. How can I remove this? I've already tried: cell.backgroundColor = [UIColor clearColor]; cell.textLabel

UILabel view disappear when the height greater than 8192

六眼飞鱼酱① 提交于 2019-12-08 19:09:42
问题 Assigning large string to UILabel. And, adding this label into a scroll view. The UILabel disappear when the UILabel height larger than 8192pt (which is 2^13). Is this an iOS bug? And should I use other implementation to render such amount of string? Should I use table view with cell? UPDATE The code that will display the UILabel: UILabel *label = [[UILabel alloc] init]; label.backgroundColor = [UIColor clearColor]; label.text = rumor.displayText; label.frame = CGRectMake(0, 0, self.view

-setCornerRadius not found in custom view

て烟熏妆下的殇ゞ 提交于 2019-12-08 16:47:32
问题 I am making a custom uitableviewcell class and inside this cell I have a square label. I would like to round the corners of the label(dateBox) using this: [dateBox.layer setCornerRadius:4.0f]; [dateBox.layer setMasksToBounds:YES]; I do this is other classes and it works fine, but for some reason in the uitableviewcell subclass, I get the warning "setCornerRadius method not found". Does anyone know why this might be? 回答1: You need to import QuartzCore and make sure it is an included framework

IOS - Justify UILabel like in the newspaper

自作多情 提交于 2019-12-08 14:36:24
I'm trying to align my UILabel/UITextView like in the picture below. Anyone got a lead how to justify the text that way. I have some trouble with NSTextAlignementJustified too. You can achieve this with the use of NSAttributedString, by setting the alignment and by setting firstLineHeadIndent to something close to zero (why? hmmmm... well I don't know): NSMutableParagraphStyle *paragraphStyles = [[NSMutableParagraphStyle alloc] init]; paragraphStyles.alignment = NSTextAlignmentJustified; paragraphStyles.firstLineHeadIndent = 0.001f; NSString *stringTojustify = @"Lorem ipsum dolor sit amet,

NSBackgroundColorAttributeName for multiline attributed strings labels

这一生的挚爱 提交于 2019-12-08 13:48:27
问题 I'm trying to display a map with information overlayed. To improve legibility on the map, I tried several ways (text shadows, outline text, darkening the map), but nothing really worked well – hence I tried to use a semitransparent box underneath the text. I'm using the NSBackgroundColorAttributeName , which – as you can see in the screenshot – works fine for single line labels. In the multiline case though, the box seems to fill a whole line, even if there are no characters above. Is this a