简体   繁体   中英

send programmatic UIView to back against UIView added in Storyboard

I'm creating UIView programmatically and called this UIView captureImage . This UIView captureImage display the image that I capture from camera and the parentView I called it self.frameForCapture . But the problem is, It always overlap the UIView that I add to the storyboard.

Update Post:

Here is the image that I'm trying to make in my app. 在此处输入图片说明

Black View is my parentView and I called it self.frameForCapture. Blue View is childView, and I add it using the storyboard. Red View is childView, and I programmatically added to the parentView. But the time I add it the redView. It always overlap the blueView, i use this addSubView: . But if I used these

[self.frameForCapture bringSubviewToFront:captureImage]; 
[self.frameForCapture sendSubviewToBack:captureImage];

nothing happen. I used this code:

self.newalbumImageView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.newalbumImageView setContentMode:UIViewContentModeScaleAspectFill];
 self.newalbumImageView.image = self.albumImage;
UIView * captureImage = [[UIView alloc] initWithFrame:self.frameForCapture.frame];
[captureImage addSubview:self.newalbumImageView];
[self.frameForCapture addSubview:captureImage];

there are a few things that can help you look at this question How to make a UIView always appear at the front? just link the headerview to .h file and use myAlwaysOnTopView.layer.zPosition = MAXFLOAT; another thing is that when you use [self.frameForCapture sendSubviewToBack:captureImage]; the redview will still be on top of self.frameForCapture if don't want it like that you can hide it or even remove if you still have this problem just tag me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM