UILabel 竖直左居中OC代码
时间: 2023-03-28 12:02:58 浏览: 194
CAKeyframeAnimation动画(UILabel左右晃动)OC 版
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
label.text = @"这是一个竖直居中的文本";
label.numberOfLines = ;
label.textAlignment = NSTextAlignmentCenter;
label.lineBreakMode = NSLineBreakByCharWrapping;
label.font = [UIFont systemFontOfSize:14];
CGSize size = [label sizeThatFits:CGSizeMake(width, MAXFLOAT)];
label.frame = CGRectMake(x, y + (height - size.height) / 2, width, size.height);
[self.view addSubview:label];
阅读全文