在表格视图中为图像视图创建子视图叠加层

时间:2015-07-23 01:00:23

标签: ios xcode swift parse-platform

我想创建一个子视图,弹出UITableView,其中包含UIImageViewcell的全屏显示图片,右上角有一个退出按钮以及另一个UITextViewcell

底部cell的{​​{1}}
UITextView

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:3)

使用以下代码..

func imageTapped(gesture: UIGestureRecognizer) {

    var overlay : UIView = UIView(frame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height))

    var imageView : UIImageView = UIImageView(image: (gesture.view as! UIImageView).image) // This includes your image in table view cell

    imageView.frame = CGRectMake(0, 0, 0, 0) // set up according to your requirements

    var doneBtn : UIButton = UIButton(frame: CGRectMake(0, 0, 0, 0)) // set up according to your requirements
    doneBtn.addTarget(self, action: "pressed:", forControlEvents: .TouchUpInside)

    overlay.addSubview(imageView)
    overlay.addSubview(doneBtn)

    self.view.addSubview(overlay)
}

func pressed(sender: UIButton!) {

    sender.superview?.removeFromSuperview()
}