【问题标题】:send programmatic UIView to back against UIView added in Storyboard针对 Storyboard 中添加的 UIView 发送程序化 UIView
【发布时间】:2016-01-13 08:48:59
【问题描述】:

我正在以编程方式创建 UIView,并将其命名为 UIView captureImage。这个UIView captureImage 显示我从相机和父视图捕获的图像,我称之为self.frameForCapture。但问题是,它总是与我添加到情节提要的 UIView 重叠。

更新帖子:

这是我试图在我的应用中制作的图像。

Black View 是我的 parentView,我称之为 self.frameForCapture。 Blue View 是 childView,我使用情节提要添加它。 红色视图是childView,我以编程方式添加到parentView。 但是我把它添加到redView的时候。它总是与 blueView 重叠,我使用这个 addSubView:。 但是如果我使用这些

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

什么都没有发生。 我使用了这段代码:

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];

【问题讨论】:

  • 这是可能的,但您需要使您的视图层次结构更清晰。这并没有提供足够的信息来确切说明发生了什么问题。
  • 对不起,我会更新我的帖子。
  • 你确定captureImageframeForCapture 的孩子吗?您还说“它们具有相同的 parentView。”
  • 是的。 captureImage 是 frameForCapture 的子对象
  • 我更新了我的帖子。希望得到您的建议

标签: ios objective-c uiview


【解决方案1】:

有几件事可以帮助你看这个问题How to make a UIView always appear at the front? 只需将 headerview 链接到 .h 文件并使用 myAlwaysOnTopView.layer.zPosition = MAXFLOAT; 另一件事是当你使用[self.frameForCapture sendSubviewToBack:captureImage]; 如果不想这样,redview 仍将位于 self.frameForCapture 之上,您可以将其隐藏甚至删除 如果你仍然有这个问题,请标记我

【讨论】:

    猜你喜欢
    • 2013-07-14
    • 1970-01-01
    • 2013-09-14
    • 1970-01-01
    • 1970-01-01
    • 2015-05-28
    • 2014-05-02
    • 2016-06-29
    • 2012-04-12
    相关资源
    最近更新 更多