2011-09-15 21 views
1

當前我將UILable放置在縱向模式中。在AutorotateToInterfaceOrientation中移動中心

UILabel* lbl=[[UILabel alloc] initWithFrame:CGRectMake(280, 10, 150, 45)]; 
[email protected]"3 out of 5 views"; 
lbl.font=[UIFont fontWithName:@"Arial" size:18]; 
lbl.textColor=[UIColor whiteColor]; 
lbl.backgroundColor=[UIColor clearColor]; 

[cell.contentView addSubview:lbl]; 

當位置改變爲橫向模式時,它不在橫向位置的中心。所以,我嘗試了autoresizingMask,但效果不佳。

lbl.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin; 

如何將UILable始終置於橫向和縱向模式中?

回答

2

得到它

[lbl setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];