iOS常见设置

本文详细介绍了UILabel的各种属性设置方法,包括文字、字体、颜色及对齐方式等,并提供了UIFont的常见创建方法。同时,文章还讲解了UIButton的常用设置方法,如文字、颜色、图片及其状态设置,以及如何为按钮设置特定的字体。

UILabel设置

@property(nonatomic,copy)NSString *text;//显示文字

@property(nonatomic,retain)UIFont *font;//字体

@property(nonatomic,retain)UIColor *textColor;//文字颜色

@property(nonatomic)NSTextAlignment textAlignment;//对齐模式(左对齐,居中对齐,右对齐)

 

UIFont代表字体,常见的创建方法

+(UIFont *)systemFontOfSize:(CGFloat)fontSize;//系统默认字体

+(UIFont *)boldSystemFontOfSize:(CGFloat)fontsize;//粗体

+(UIFont *)italicSystemFontOfSize:(CGFloat)fontSize;//斜体

 

UIButton的常见设置

-(void)setTitle:(NSString *)title forState:(UIControlState)state;//设置按钮的文字

-(void)setTitleColor:(UIColor *)color forState:(UIControlState)state;//设置按钮的颜色

-(void)setImage:(UIImage *)image forState:(UIControlState)state;//设置按钮内的小图片

-(voif)setBackgroundImag:(UIImage *)image forState:(UIControlState)state;//设置按钮的背景图片

设置按钮的文字字体 (需要拿到按钮内部的label来设置)

btn.titleLabel.font = [UIFont systemFontOfSize:12];

-(NSString *)titleForState:(UIControlState)state;//获得按钮的文字

-(UIColor *)titleColorForState:(UIControlState)state;//获得按钮多文字颜色

-(UIImage *)imageForState:(UIControlState)state;//获得按钮内部的小图片

-(UIImage *)backgroundImageForState:(UIControlState)state;//获得按钮的背景图片

 

转载于:https://www.cnblogs.com/YTzZ/p/4687330.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值