iOS代码灵异事件

//注意这里我设置了-30
UIView *datiView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, Screen_width, -30)];
[_contentView addSubview:datiView];

//马上重新设置尺寸
[datiView setFrame:CGRectMake(0, 200, Screen_width, 88)];
UILabel *datiLab = [[UILabel alloc] initWithFrame:CGRectMake(datiView.frameWidth-150-15, 0, 150, datiView.frameHeight)];
[datiLab setText:@"最高3000步"];
datiLab.textAlignment=NSTextAlignmentRight;

[datiView addSubview:datiLab];

最后不管你怎么设置 加载在view内的lab就会一直是歪的!

 

你可能感兴趣的:(iOS开发日常)