
UIbutton *button = [UIbutton buttonWithType:UIbuttonTypeCustom];[button setTitle:@"My Title" forState:UIControlStatenormal];button.frame = myCustomrect;UIcolor *Fontcolor = [UIcolor colorWithRed:0.43 green:0.84 blue:0.86 Alpha:0.9];[button setTitlecolor:Fontcolor forState:UIControlStatenormal];button.backgroundcolor = [UIcolor whitecolor];button.TitleLabel.textAlignment = NSTextAlignmentCenter;button.TitleLabel.Font = [UIFont FontWithname:@"Cooperplate" size:9];[button addTarget:self action:@selector(moreDetails:) forControlEvents:UIControlEventtouchUpInsIDe]; [self.vIEw addSubvIEw:button];
我试图以编程方式向视图添加按钮.
MyCustomrect的参数是(0,75,50).
两件事情:
a)无论我输入什么字体,它总是显示系统字体.
b)尺寸也根本没有变化.我尝试增加字体大小,它没有改变,我尝试减少字体大小,它也没有改变.
我究竟做错了什么?
解决方法 您可以在项目中使用自己的自定义字体作为 mentioned here将自定义字体添加到项目后,可以将其用作,
[button.TitleLabel setFont:[UIFont FontWithname:@"Cooperplate" size:24.0]];
First,in XCode locate the application .pList file. Usually called,
[YOUR_APP_name]-Info.pList. Once you locate the file,add a new row of
key: “Fonts provIDed by application”. XCode will create the first
key/value pair for you. Here is a screenshot of my .pList file entry.
Image
总结Add the name of the Font file in the “value” column. Be sure to spell
the name of the Font file EXACTLY as it is in seen in the List of
files in your project. This is NOT the name you will be referencing
from within your UIFont statement. This is just so your app kNows
where to find the Font you will be referencing.Next,you need the name of the Fontface you are going to use. Now you reference it in your app.
以上是内存溢出为你收集整理的iphone – UIButton文本大小问题全部内容,希望文章能够帮你解决iphone – UIButton文本大小问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)