UIView rounded corners with PatternImage

142 Views Asked by At

Here, cornerRadius is not working with PatternImage, Could you please help me?

- (void)viewDidLoad
{
    [super viewDidLoad];

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

There are 1 best solutions below

0
On BEST ANSWER

You need to clip your view or the background will bleed out.

myView.layer.maskToBounds = YES;

You could also use the UIView method, but I figured you were already in the layer so it would look cleaner that way haha. They do the same thing.

myView.clipsToBounds = YES;