What is the fastest/simplest way to change only the size of the existing font on a UIButton? (pointSize is read-only)
Thanks in advance.
UILabel* titleLabel = button.titleLabel;
titleLabel.font = [titleLabel.font fontWithSize:12345];
Related
my UIView has a UILabel and a UIWebView inside, the UILabel is in the top, the UILabel has the height variable:
theTitle.text = [NSString stringWithFormat:#"%#", noticeTitle];
theTitle.lineBreakMode = UILineBreakModeWordWrap;
theTitle.numberOfLines = 0;
[theTitle sizeToFit];
how can I start the UIWebView below the UILabel?
Thank you in advance.
Regards.
I think you want your webView to be displayed just below the label.If the string you want to display is dynamic then your Label size must also be dynamically set according to the string size. So for adjusting your label size Just follow the link :
Adjust UILabel height depending on the text
And then you can get the height of your label by :
int height = theTitle.frame.size.height;
You then set your webView frame according to this height + yValue of label frame.
I am wondering how I can set the backgroundColor of my UIView to the scroll View Textured background color.
this is the way I plan on implementing it but im just not sure what the patternImage is called .
jumpBarContainer.backgroundColor = [UIColor colorWithPatternImage:????]
any help would be greatly appreciated.
jumpBarContainer.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
[UIColor scrollViewTexturedBackgroundColor]
is what you need to use.
I have used UITextView in my application. Now this might be a dumb question but how can I change the font size of text in it.
if any1 can help with this would be appreciated.
thanks
you have to set font by code
yourtextViewObject.font = [UIFont systemFontOfSize:14];
Try this...
[yourtextview setFont:[UIFont boldSystemFontOfSize:13.0f]];
UITextView has a read-write font property declared:
#property(nonatomic,retain) UIFont *font;
The UIFont class declares a factory method:
+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize;
So create a new UIFont instance and then call -setFont: on your UITextView with the font instance.
I want to make my label as shown in the image
I know I can get this effect by putting image view on it.
but is there any other method to do ?
How can I put line on label ?
Try this,
UILabel *blabel = [[UILabel alloc] initWithFrame:CGRectMake(XX, 6, 271, 26)];
blabel.text = #"Hellooooooo";
blabel.textAlignment = UITextAlignmentCenter;
blabel.backgroundColor = [UIColor clearColor];
blabel.textColor = [UIColor blackColor];
blabel.font = [UIFont systemFontOfSize:14];
[scrollDemo addSubview:blabel];
//underline code
CGSize expectedLabelSize = [#"Hellooooooo" sizeWithFont:blabel.font constrainedToSize:blabel.frame.size lineBreakMode:UILineBreakModeWordWrap];
UIView *viewUnderline=[[UIView alloc] init];
viewUnderline.frame=CGRectMake((blabel.frame.size.width - expectedLabelSize.width)/2, expectedLabelSize.height + (blabel.frame.size.height - expectedLabelSize.height)/2, expectedLabelSize.width, 1);
viewUnderline.backgroundColor=[UIColor blackColor];
[scrollDemo addSubview:viewUnderline];
[viewUnderline release];
The line above will appear below the text. You just need to change Y for UIView and it'll do wonders :)
put another label with "_" over it
transparent background.
you can create UIView with line's height and width and give background color to it. Put UIView over your UILabel .
For one of my projects I've created an UILabel subclass, which supports multiline text, underline, strikeout, underline/strikeout line offset, different text alignment and different font sizes.
Please see provided link for more info and usage example.
https://github.com/GuntisTreulands/UnderLineLabel
Place a UIImageView with line image on your label so when you run application it will fit.
I have to set the font size and font family of a dynamically created textView, so that it gives same appearance as the one generated using Interface builder. Any idea how to do this?
UITextView *textView
...
[textView setFont:[UIFont fontWithName:#"ArialMT" size:16]]
You try this
[textView setFont:[UIFont systemFontOfSize:15]];
or
[textView setFont:[UIFont boldSystemFontOfSize:15]];
or you want to give fontname and size then you try this
[textView setFont:[UIFont fontWithName:#"arial" size:16]]
There is a property called font in UITextView,
#property(nonatomic, retain) UIFont *font
You can do like this:
yourTextView.font = builderTextView.font
may be I am too late but wanted to post my answer as its most relevant with current SDK.
I have used following line of code and work like charm in iOS 8.0
Swift Version:
self.textView.font = [UIFont systemFontOfSize:fontSize];
where fontSize is CGFloat Value.
In IB, select the text area and use the inspector to set the editability (it’s next to the text color). To set the font, you have to bring up the font window (command-T). It may help to have some text in the view when you change the font and size.
textView.font = UIFont(name: "Times New Roman", size: 20)
This worked for me (Swift 4 using in Swift Playgrounds on Xcode).