刚才在修改应用上的三个UILabel,后两个UILabel是通过copy第一个UILabel的代码,然后修改实现的。
悲剧的是修改名字的时候,有一行代码的名字没有修改,造成第一个UILabel的对齐方式被多次赋值。
例如:
UILabel * label1 = [UILabel alloc] initWithRect: CGRectMake(10, 0, 60, 30)];
label1.textAlignment = NSTextAlignmentLeft;
UILabel * label2 = [UILabel alloc] initWithRect: CGRectMake(10, 30, 60, 30)];
label1.textAlignment = NSTextAlignmentCenter;
UILabel * label3 = [UILabel alloc] initWithRect: CGRectMake(10, 60, 60, 30)];
label3.textAlignment = NSTextAlignmentLeft;