Hello I'd like to achieve at the same time rounded corners and a background composed by tiling a little png (OPERATOR_VIEW_BACKGROUND_IMAGE
). My main goal is to allow a designer to fill the background of a View by inserting the right image in the project resources.
[triggerView setFrame:CGRectMake(0, 0, ICONS_WIDTH, iconFrameHeight)];
[triggerView.layer setCornerRadius:borderRadius];
[triggerView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:OPERATOR_VIEW_BACKGROUND_IMAGE]]];;
I don't know why but triggerView loose the CornerRadius setting when I add the last line.
triggerView
is a UIView built with interface builder and modified in its superView viewDidLoad programmatically, with the code above.
Where I'm wrong?
EDIT: I haven't mentioned that If I use a simple UIColor like: [UIColor orangeColor]
It works well. So It's something related to the "patternImage" thing.
EDIT: I've tried also this code, working on the layer background of my view:
[triggerView setFrame:CGRectMake(0, 0, ICONS_WIDTH, iconFrameHeight)];
triggerView.backgroundColor = [UIColor clearColor];
UIImage *img = [UIImage imageNamed:OPERATOR_VIEW_BACKGROUND_IMAGE];
triggerView.layer.backgroundColor = [UIColor colorWithPatternImage:img].CGColor;
triggerView.layer.cornerRadius = radius;
[img release];
[self.view addSubview:triggerView];
Now I get a transparent background but the corners are rounded;