ios - Why my frame of my uiimageview is not updated? -
i have iboutlet
imageprofile (uiimageview
). when set frame in code, uiimageview
frame not updated layer updated, can tell me why ?
@iboutlet weak var imageprofile: uiimageview! override func viewdidload() { super.viewdidload() setdesign() } func setdesign() { var newframe=imageprofile.frame newframe.origin.x=50 newframe.origin.y=100 newframe.size.width=150 newframe.size.height=150 imageprofile.frame=newframe imageprofile.layer.bordercolor = uicolor.whitecolor().cgcolor imageprofile.backgroundcolor=uicolor.blackcolor() imageprofile.layer.cornerradius = 75 imageprofile.layer.borderwidth=3 imageprofile.clipstobounds = true imageprofile.updateconstraints() }
if delete iboutlet
, try this, frame updated :
var imageprofile: uiimageview? override func viewdidload() { super.viewdidload() setdesign() } func setdesign() { var image: uiimage = uiimage(named: "iconsuggestselect.png")! imageprofile = uiimageview(image: image) imageprofile!.frame = cgrectmake(100,100,100,200) imageprofile!.layer.bordercolor = uicolor.whitecolor().cgcolor imageprofile!.backgroundcolor=uicolor.blackcolor() imageprofile!.layer.cornerradius = 75 imageprofile!.layer.borderwidth=3 imageprofile!.clipstobounds = true imageprofile!.updateconstraints() imagecover.addsubview(imageprofile!)
}
Comments
Post a Comment