Programmatically change the height and width of a UIImageView Xcode Swift

前端 未结 7 852
一整个雨季
一整个雨季 2021-02-03 23:00

Hey for some reason I am struggling with trying to set the height and width of one of my image views. I want to set it so the height only goes for 20% of my screen. I know to re

7条回答
  •  礼貌的吻别
    2021-02-03 23:34

    u can use this code

    var imageView = UIImageView(image: UIImage(name:"imageName"));
    imageView.frame = CGrectMake(x,y imageView.frame.width*0.2,50);
    

    or

    var imageView = UIImageView(frame:CGrectMake(x,y, self.view.frame.size.width *0.2, 50)
    

提交回复
热议问题