我在main.storyboard中有3个图像响应我的UIImageView,我只想让我的一个图像(image.image = UIImage(named:"InnieBulb")
)增加到一个高度(可能是10%{298x330}),而剩下的2个停留相同。最简单的方法是什么?提前谢谢你帮助我。
import UIKit
class CorrectController: UIViewController {
@IBOutlet var label1: UILabel!
@IBOutlet var scorelabel: UILabel!
@IBOutlet var button1: UIButton!
@IBOutlet var image: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
self.button1.layer.cornerRadius = CGFloat(Float(5.0));
button1.titleLabel?.textAlignment = NSTextAlignment.center;
let returnValue: Int = UserDefaults.standard.integer(forKey: "userScore")
scorelabel.text = "Your Score: \(returnValue)/11"
if (1...3 ~= returnValue) {
if (returnValue == 1)
{
label1.text = "Fin-tastic !"
button1.setTitle("Let's bubble on", for: .normal)
}
else if (returnValue == 2)
{
label1.text = "You're Fun !"
button1.setTitle("Bubbly Bloop", for: .normal)
}
else if (returnValue == 3)
{
label1.text = "You're Great !"
button1.setTitle("Let's Drift On", for: .normal)
}
image.image = UIImage(named:"InnieBubbles")
}
else if (4...6 ~= returnValue) {
if (returnValue == 4)
{
label1.text = "You're Sexy !"
button1.setTitle("Let's Swim On", for: .normal)
}
else if (returnValue == 5)
{
label1.text = "You're Fabulous !"
button1.setTitle("Let's Angle On", for: .normal)
}
else if (returnValue == 6)
{
label1.text = "You're Creative !"
button1.setTitle("Let's Moove On", for: .normal)
}
image.image = UIImage(named:"InnieBulb")
}
else if (7...10 ~= returnValue) {
if (returnValue == 7)
{
label1.text = "You're a Genius !"
button1.setTitle("Let's Trail On", for: .normal)
}
else if (returnValue == 8)
{
label1.text = "You're a Thinker !"
button1.setTitle("Let's Hook On", for: .normal)
}
else if (returnValue == 9)
{
label1.text = "Blimey !"
button1.setTitle("Bloop Bloop", for: .normal)
}
else if (returnValue == 10)
{
label1.text = "You're Bursting with Solutions !"
button1.setTitle("Innie, Here We Come!", for: .normal)
}
image.image = UIImage(named:"InnieKOI")
}
}
答案 0 :(得分:0)
在tf.global_variables_initializer()
结束时,请写下这些行:
viewDidLoad()
答案 1 :(得分:0)
行后
image.image = UIImage(named:"InnieBubbles")
加入
image.frame.size.height = //your new height here
例如
image.frame.size.height = image.frame.height * 1.1
image.frame.height
返回仅获取值。 image.frame.size.height
可编辑。