自定义UILabel,添加verticalAlignment属性
来源:互联网 发布:linux 执行二进制文件 编辑:程序博客网 时间:2024/05/30 05:42
效果
- —–bottom
代码:
@synthesize verticalAlignment = _verticalAlignment;- (void)setVerticalAlignment:(VerticalAlignment)verticalAlignment{ _verticalAlignment = verticalAlignment; [self setNeedsDisplay];}- (void)drawTextInRect:(CGRect)rect{ CGRect actualRect = [self textRectForBounds:rect limitedToNumberOfLines:self.numberOfLines]; [super drawTextInRect:actualRect];}- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines{ CGRect textRect = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines];// 获取文字的rect textRect = CGRectMake(bounds.origin.x, textRect.origin.y, bounds.size.width, textRect.size.height);// 微调 switch (self.verticalAlignment) { case KLTextVerticalAlignmentTop: textRect.origin.y = bounds.origin.y; break; case KLTextVerticalAlignmentBottom: textRect.origin.y = bounds.origin.y + bounds.size.height - textRect.size.height; break; case KLTextVerticalAlignmentMiddle: // Fall through. default: textRect.origin.y = bounds.origin.y + (bounds.size.height - textRect.size.height) / 2.0; break; } return textRect;}
阅读全文
0 0
- 自定义UILabel,添加verticalAlignment属性
- UILabel自定义文本各种属性能
- dedecms添加自定义属性
- ActiveX 添加自定义属性
- magento添加添加自定义属性
- UILabel属性
- UILabel属性
- UILabel属性
- UILabel属性
- UILabel属性
- UILabel属性
- UILabel属性
- UILabel属性
- UILabel 属性
- 自定义UILabel
- 自定义 UIlabel
- 给UILabel添加自定义手势后没有反应
- 为TreeNode添加自定义属性
- 百度竞价要懂的公式
- copy && mutableCopy
- JScrollPane中放JTable,但滚动条一直不显示
- CDH5.10+安装过程报错:Unable to verify database connection
- 支持最小值的栈设计
- 自定义UILabel,添加verticalAlignment属性
- 分析ReentrantLock的实现原理
- IntelliJ IDEA中maven导入本地jar包
- textarea 限制输入字符个数
- activiti简单介绍
- .Net Core配置与自动更新
- POJ-1459 Power Network
- Kafka实战篇之搭建Kafka运行环境
- Orchard Core一分钟搭建ASP.NET Core CMS