iOS Button title换行居中。
来源:互联网 发布:linux执行器 编辑:程序博客网 时间:2024/05/28 23:21
效果如图:
代码:
NSString * title = @"11-28*8:00";
NSArray * stringArr = [titlecomponentsSeparatedByString:@"*"];
NSString * endTitle = [NSStringstringWithFormat:@"%@\n%@",stringArr[0],stringArr[1]];
selectBtn.titleEdgeInsets =UIEdgeInsetsMake(0,20, 0,0);
selectBtn.titleLabel.numberOfLines =0;
[selectBtn setTitle:endTitleforState:UIControlStateNormal];
1. 首先把字符串按你想要的分割法分成数组
2. 然后重新拼接字符串,数组之间用/n连接
3. 记得设置numberOfLines 还有这时候 button的titleLabel textAlignment 设置居中没有用的。要设置titleEdgeInsets
1 0
- iOS Button title换行居中。
- IOS Button title居中实现方法实例
- iOS 导航栏Title不居中
- iOS 导航栏Title不居中
- IOS 更新Button title 闪动解决
- title换行
- iOS 多个label/button自动换行
- iOS title view不居中的处理办法
- iOS如何让button的title居左显示
- iOS navigationbar背景颜色和button title的问题
- ios 设置button的title靠左显示
- ios代码调整button图片image文字title位置
- ios代码调整button图片image文字title位置
- ios代码调整button图片image文字title位置
- title换行、Confirm中换行
- 如何使TITLE居中
- 让title居中!!!!
- android title 居中
- Error running Tomcat8: Address localhost:1099 is already in use 的错误
- linux下提示找不到主机异常
- 从比特币说起, “区块链”到底是什么
- C# 数据类型和字节长度
- 将数字以百分比的形式呈现(swift)
- iOS Button title换行居中。
- 为什么静态成员、静态方法中不能用this和super关键字
- 信息检索模型与评估
- MySQL数据类型和常用字段属性总结
- 区块链技术是什么鬼
- 关于中文字符串乱码解决方案
- 类方法创建控件
- keepalived+redis实现主备
- JDK1.7的新特性