我认为 2 个标签,较大的一个和较小的一个正好位于屏幕的中心。更改坐标似乎对它们的放置位置没有影响。为什么?
理想情况下,我希望它们具有相同的大小,而不是重叠,并且一个在另一个之下,以便它们几乎覆盖整个屏幕。
我认为 labelframe 使用格式 - 起始坐标,大小。我的出身在哪里?是在屏幕的左上角吗?我可以在 xcode 中翻译它吗?
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UILabel *label1;
@end
@implementation ViewController
- (void)viewDidLoad{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
CGRect labelFrame = CGRectMake(-200.0f,0.0f, 200.0f, 200.0f);
self.label = [[UILabel alloc] initWithFrame:labelFrame];
//self.label.adjustsFontSizeToFitWidth = YES;
self.label.text = @"One two three four five six seven eight nine.";
self.label.font = [UIFont boldSystemFontOfSize:28.0f];
self.label.numberOfLines = 5;
self.label.center = self.view.center;
[self.view addSubview:self.label];
CGRect labelFrame1 = CGRectMake(600.0f,600.0f, 100.0f, 100.0f);
self.label1 = [[UILabel alloc] initWithFrame:labelFrame1];
self.label1.text = @"One 1 two three four five six seven eight nine.";
self.label1.font = [UIFont boldSystemFontOfSize:18.0f];
self.label1.numberOfLines = 0;
self.label1.center = self.view.center;
[self.view addSubview:self.label1];
}
@end