UILabel* labelJinE = [[UILabel alloc]init];
labelJinE.text = @"到账金额:--元";
labelJinE.font = [UIFont systemFontOfSize:16];
[labelJinE sizeToFit];
labelJinE.center = CGPointMake((WINDOW_WIDTH-ButtonWide*3)/4*1+labelJinE.bounds.size.width/2, 72/2);
[viewButtom addSubview:labelJinE];
其中[labelJinE sizeToFit]
要写在center之前,否则先设置了center,后在自适应frame,会有些偏差,如果要加上确定的frame,代码如下
UILabel* labelJinE = [[UILabel alloc]init];
labelJinE.text = @"到账金额:--元";
labelJinE.font = [UIFont systemFontOfSize:16];
labelJinE.bounds = CGRectMake(0, 0, 96, 44);
labelJinE.center = CGPointMake((WINDOW_WIDTH-ButtonWide*3)/4*1+labelJinE.bounds.size.width/2, 72/2);
[viewButtom addSubview:labelJinE];
其中设置buounes需要在center之前,不需要添加sizeToFit,前提确保你的bounds 是对的
原文地址:http://blog.csdn.net/u010742414/article/details/45969551