I couldn’t find anything on how you can center the ‘image’ when you use (maybe you can’t):
[self setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]]];
Setting my [self setContentMode:UIContentModeCenter]; doesnt help.
Do I have to manually draw the image (either in drawRect or set the content of the CALayer? Which one if preferable?
I think you’re on the wrong path here: you create a
UIColorfrom a pattern (pattern already implies this is a repeating image). All in all- you can’t have your pattern not repeat and centered.If you just want simple image as background of your
UIView, just add it as a subview and center it.Now – add more subviews to your “
yourUIView” view and they’ll show on top of the image – thus the image becoming the background.So… no need to draw anything yourself.