Set order on displaying paths/images

半世苍凉 提交于 2019-12-10 00:33:09

问题


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?


回答1:


Add image to UIImageView :

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



回答2:


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).



来源:https://stackoverflow.com/questions/15160157/set-order-on-displaying-paths-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!