UILabel 竖直居中OC代码
时间: 2023-03-28 18:02:57 浏览: 166
iOS中UILabel设置居上对齐、居中对齐、居下对齐及文字置顶显示
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(, , 100, 50)];
label.text = @"Hello World";
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor blackColor];
label.backgroundColor = [UIColor whiteColor];
label.numberOfLines = ;
[label sizeToFit];
label.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
阅读全文