【问题标题】:UIView rounded corners with PatternImage带有 PatternImage 的 UIView 圆角
【发布时间】:2012-05-12 12:23:21
【问题描述】:

这里,cornerRadius 无法使用 PatternImage,您能帮帮我吗?

- (void)viewDidLoad
{
    [super viewDidLoad];

    myView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background.png"]];
    myView.layer.cornerRadius = 10.0;
}

【问题讨论】:

    标签: objective-c xcode uiview cornerradius


    【解决方案1】:

    您需要裁剪视图,否则背景会溢出。

    myView.layer.maskToBounds = YES;
    

    您也可以使用 UIView 方法,但我认为您已经在图层中,这样看起来会更干净哈哈。他们做同样的事情。

    myView.clipsToBounds = YES;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-26
      • 2011-06-12
      • 2013-05-15
      • 2012-07-11
      相关资源
      最近更新 更多