2014-04-04 2 views
2

iOS7.1 로의 업데이트 이후로 내 앱의 UILabels가 모양이 변경되었습니다. OS를 업데이트하기 전에 모든 UILabels의 모서리가 둥글게되었습니다. iOS7.1에서 이제는 모두 날카로운 모서리를 갖습니다.UILabel 둥근 모서리는 iOS 7.1에서 날카롭게 나타납니다.

은 내가 아래에 사용하는 코드를 삽입합니다. UILabels을 원래 모양으로 복원하는 방법에 대한 도움을 주시면 감사하겠습니다.


뷰 컨트롤러의 구현 파일의


맨 다음 UILabel의 생성에 대한

#import <QuartzCore/QuartzCore.h> 

코드입니다. 나는 (내가 생각하는) 관련 줄을 주석으로 표시했다.

CGRect labelRect = CGRectMake(20, 20, 200, 100); 

    NSString *theText = [self info]; 
    CGSize size = [theText sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(labelRect.size.width, 10000) lineBreakMode:NSLineBreakByWordWrapping]; 

    UILabel *theLabel = [[UILabel alloc] initWithFrame:labelRect]; 
    [theLabel setNumberOfLines:0]; 
    [theLabel setText:theText]; 
    [[theLabel layer] setCornerRadius:15]; // THIS IS THE RELEVANT LINE 

    // For iOS7 
    if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) 
     [theLabel setBackgroundColor:[UIColor whiteColor]]; 

    [[self view] addSubview:theLabel]; 
+0

봅니다 만'[[theLabel 계층] setMasksToBounds : YES]를 시도 YES' –

답변

13

설정 theLabel.clipsToBounds = YES, 또는 theLabel.layer.masksToBounds = YES. 둘 중 하나가 작동합니다.

+0

'에 라벨의 재산'clipsToBounds'을 설정',하지만 내가 원하는대로 그냥했다. – OscarWyck

0

사용이

CGRect labelRect = CGRectMake(20, 20, 200, 100); 

NSString *theText = [self info]; 
CGSize size = [theText sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(labelRect.size.width, 10000) lineBreakMode:NSLineBreakByWordWrapping]; 

UILabel *theLabel = [[UILabel alloc] initWithFrame:labelRect]; 
[theLabel setNumberOfLines:0]; 
[theLabel setText:theText]; 
[[theLabel layer] setCornerRadius:15]; // THIS IS THE RELEVANT LINE 
[theLabel.layer setMasksToBounds:YES]; ///missing in your code 
// For iOS7 
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) 
    [theLabel setBackgroundColor:[UIColor whiteColor]]; 

[[self view] addSubview:theLabel]; 
관련 문제