UILabel *label = [[UILabel alloc] initWithFrame:self.view.bounds];label.text = @"各种居中";label.textAlignment = UITextAlignmentCenter;
[self.view addSubview:label];[object Object]
2 回答
守着一只汪
TA贡献1872条经验 获得超3个赞
@implementation UILabel (VerticalUpAlignment)- (void)verticalUpAlignmentWithText:(NSString *)text maxHeight:(CGFloat)maxHeight { CGRect frame = self.frame; CGSize size = [text sizeWithFont:self.font constrainedToSize:CGSizeMake(frame.size.width, maxHeight)]; frame.size = CGSizeMake(frame.size.width, size.height); self.frame = frame; self.text = text; }@end
- 2 回答
- 0 关注
- 147 浏览
添加回答
举报
0/150
提交
取消