博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 开发笔记-UILable/UIFont/UIButton常见设置
阅读量:4697 次
发布时间:2019-06-09

本文共 1129 字,大约阅读时间需要 3 分钟。

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; 设置按钮内部的小图片

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

btn.titleLabel.font = [UIFont systemFontOfSize:13]; 设置按钮的文字字体(需要拿到按钮内部的label来设置)

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

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

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

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

 

转载于:https://www.cnblogs.com/jys509/p/4761547.html

你可能感兴趣的文章
MySQL 网络访问连接
查看>>
在aws ec2上使用root用户登录
查看>>
数据访问 投票习题
查看>>
cnblog!i'm coming!
查看>>
使用点符号代替溢出的文本
查看>>
Axios 中文说明
查看>>
fatal: remote origin already exists.
查看>>
gridview 自定义value值
查看>>
2018二月实现计划成果及其三月规划
查看>>
类名.class和getClass()区别
查看>>
12/17面试题
查看>>
LeetCode 242. Valid Anagram
查看>>
JSP表单提交乱码
查看>>
如何适应现代雇佣关系
查看>>
团队项目(第五周)
查看>>
SQL 优化经验总结34条
查看>>
开源 视频会议 收藏
查看>>
核心J2EE模式 - 截取过滤器
查看>>
.net开源CMS
查看>>
JdbcTemplate
查看>>