I have a UIImageView
that I'm adding to a UIAlertController
. I want the image view to be smack dab in the middle of the screen, but when toying around with the CGRectMake
coordinates, I'm finding that my y
value only appears on screen if given a negative coordinate.
var alert = UIAlertController()
let myImage = UIImage(named: "image")
var imageView = UIImageView(frame:CGRectMake((UIScreen.mainScreen().bounds.width/2) - 60, -300, 120, 120))
imageView.image = myImage
alert.view.addSubview(imageView)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
Why do I need a negative y
value coordinate in my var imageView
declaration to show on screen? If the alert.view.bounds
= (0,0,335,667)
then shouldn't a negative y
value mean the view will appear off screen?
Otherwise, am I just doing something wrong?