UILabel圆角在iOS 7.1中变得尖锐

UILabel圆角在iOS 7.1中变得尖锐,ios,iphone,objective-c,uilabel,ios7.1,Ios,Iphone,Objective C,Uilabel,Ios7.1,自从iOS7.1更新后,我的应用程序中的UILabel的外观发生了变化在操作系统更新之前,我所有的UILabel都有圆角,这是我的初衷。在iOS7.1中,它们现在都有尖角。 我在下面插入我使用的代码。任何关于如何将UILabel恢复为我的原始外观的帮助都将不胜感激。 视图控制器的实现文件顶部: #import <QuartzCore/QuartzCore.h> 设置label.clipsToBounds=YES,或label.layer.masksToBounds=YES。

自从iOS7.1更新后,我的应用程序中的UILabel的外观发生了变化在操作系统更新之前,我所有的UILabel都有圆角,这是我的初衷。在iOS7.1中,它们现在都有尖角。

我在下面插入我使用的代码。任何关于如何将UILabel恢复为我的原始外观的帮助都将不胜感激。



视图控制器的实现文件顶部:

#import <QuartzCore/QuartzCore.h>

设置
label.clipsToBounds=YES
,或
label.layer.masksToBounds=YES
。这两种方法都可以使用。

使用此方法

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];

尝试将标签的属性
clipstobunds
设置为
YES
仅尝试了
[[标签层]setMasksToBounds:YES]
,但效果与我所希望的一样。
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];