Set order on displaying paths/images

2019-04-17 16:28发布

I have a couple of arcs and rects in a UIView, and a UIImageView as well. I want to have the UIImageView in the background. I have ordered it in IB so that the image view is behind my labels and buttons.

First, I need to put an image in the image view, which I don't want to do in IB. I've tried this code

UIImage *myImage = [UIImage imageNamed:@"image.png"];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:@"myImage"];

But it doesn't work. After I get that working, what can I do to move my paths in front of the image view?

2条回答
啃猪蹄的小仙女
2楼-- · 2019-04-17 17:14

Add image to UIImageView :

UIImage *myImage = [UIImage imageNamed:@"image.png"];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:myImage];
[self.view addSubview:myImageView];
查看更多
放我归山
3楼-- · 2019-04-17 17:35

I think you want to draw to put a background image and on top of it want to draw circles(arcs).

If my understanding is correct. First draw the image on to the view using CGContextDrawImage() and then draw arcs on top of it. (No need to use image view).

查看更多
登录 后发表回答