johnbakers
johnbakers

Reputation: 24770

UIView rounded corners don't work with color pattern?

I have this, it works fine:

 self.rightbarshadow.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];

However, this no longer works:

 self.rightbarshadow.layer.cornerRadius=30;

If instead, I change the background color to this:

self.rightbarshadow.backgroundColor=[UIColor grayColor];

Then the cornerRadius works.

So I assume you can't round corners if you have a background color image pattern?

Upvotes: 1

Views: 380

Answers (1)

AliSoftware
AliSoftware

Reputation: 32681

Did you try to apply the backgroundColor on the layer instead of on the view?

self.rightbarshadow.layer.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]].CGColor;

Not on my Mac right now to test it in live, and I'm not sure if CGColor is compatible with pattern UIColors or if it only manages uniform colors, but you should give it a try.

Upvotes: 1

Related Questions