使用 UIImagePickerController 后如何防止 UITextField 低于 UIImageView

How to prevent UITextField from going below an UIImageView after using UIImagePickerController

我正在尝试将图像添加到 UIImageView,但是当我这样做时它会出现在 UITextField 之上。如何确保 UITextField 位于 UIImageView 的前面?

下面是我的代码:

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
    if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
        self.myImageView.image = image
        self.myImageView.contentMode = UIViewContentMode(rawValue: 1)!
        self.dismissViewControllerAnimated(true, completion: nil)
    }
}

我尝试像这样再次将 UITextField 添加到视图中,但没有成功:

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
    if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
        self.myImageView.image = image
        self.myImageView.contentMode = UIViewContentMode(rawValue: 1)!
        self.dismissViewControllerAnimated(true, completion: nil)
        self.view.addSubview(textFieldTop)
        self.view.addSubview(textFieldBottom)
    }
}

更新 所以我意识到问题不在于前面的东西,但由于某种原因我的前景色自动变为透明并且无法使用下面的前景属性进行设置。

let textAttributes = [
    NSForegroundColorAttributeName : UIColor.blackColor(),
    NSStrokeColorAttributeName : UIColor.blackColor(),
    NSFontAttributeName : UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
    NSStrokeWidthAttributeName : 3.0
]
self.view.bringSubviewToFront(viewYouWantToBeOnTop)

原来我需要将 NSStrokeWidthAttribute 设置为 -3.0。