2017-09-13 10 views
0

私はmain.storyboardの私のUIImageViewに応答する画像が3つあり、残りの2つは同じままで、私の画像(image.image = UIImage(named:"InnieBulb"))を高さ(おそらく10%{298x330})に増やしたいだけです。それを行う最も簡単な方法は何ですか?私を助けてくれてありがとうございました。 viewDidLoad()の終わりUIImageViewの高さを上げる最も簡単な方法は?

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

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は編集可能ですが

0

、これらの行を記述:行の後

if image.image == UIImage(named: "InnieBulb"){ 
    var frame = image.frame 
    frame.size.height+=10 
    image.frame = frame 
} 
関連する問題