SWIFT:UIImageView照片过去的边界

时间:2015-07-08 05:54:19

标签: swift uiimageview uiimage

有人能告诉我为什么我的照片超出了UIImageView的界限吗?

图片最后覆盖下方的按钮。

我的代码:

import UIKit

class ViewController: UIViewController {

@IBOutlet var Photo: UIImageView!

@IBOutlet var QuestionLabel: UILabel!

@IBOutlet var Button1: UIButton!

@IBOutlet var Button2: UIButton!

@IBOutlet var Button3: UIButton!

@IBOutlet var Button4: UIButton!

@IBOutlet var LabelEnd: UILabel!

var CorrectAnswer = String()


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    Hide()


    Photo.layer.cornerRadius = self.Photo.frame.size.width / 10
    Photo.clipsToBounds = true
    Photo.layer.masksToBounds = true
    Photo.layer.borderWidth = 1
    Photo.layer.borderColor = UIColor.blackColor().CGColor
    Photo.contentMode = .ScaleAspectFit
    Photo.contentMode = .ScaleAspectFill

    RandomQuestions()


}

enter image description here

enter image description here

我为这样的新手道歉,只是学习如何编码。

1 个答案:

答案 0 :(得分:0)

您确定它超出了图片视图的边界吗?

尝试打印视图框以进行仔细检查。看起来您没有从该屏幕截图设置约束 - 也许您的图片视图的大小适合。