开发者

Can we give some background image for any uiview?

开发者 https://www.devze.com 2023-01-21 19:57 出处:网络
I need to set 开发者_开发知识库some background image for my view. How can I do this?view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@\"background.png\"]];

I need to set 开发者_开发知识库some background image for my view. How can I do this?


view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];


The simpliest way is to add an imageView to your view with appropriate background image. Just make sure that it is the lowest by z-order subview by adding it first or by calling [view sendSubviewToBack:backGroundView];

As an alternative you can set your image as a contents for your view's layer:

#import <QuartzCore/QuartzCore.h>

...    
view.layer.contents = yourImage.CGImage;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号