2011-09-15 4 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]; 
있어