简体   繁体   English

UIImageView不会移动

[英]UIImageView doesn't move

Just silly thing. 只是傻事。

I placed UIImageView in the left top corner. 我把UIImageView放在左上角。 Then make a new outlet 然后做一个新的出路

@IBOutlet var rocket : UIImageView

In the method ViewDidLoad I try to move this UIImageView with different properties but it doesn't 在方法ViewDidLoad中,我尝试使用不同的属性移动此UIImageView,但它没有

rocket.image = UIImage(named: "rocket.png")
rocket.frame = CGRectMake(200,200,200,200)
rocket.bounds = CGRectMake(200,200,200,200)
rocket.center = CGPointMake(400,400)

When I start the program an image in the UIImageView appears in the top left corner without any translation. 当我启动程序时,UIImageView中的图像出现在左上角,没有任何翻译。

I guess you did not disables AutoLayout for your viewcontroller which is having that image. 我猜你没有禁用具有该图像的viewcontroller的AutoLayout。

please disable your Viewcontroller's AutoLayout property and change your code with following values so you can able to see the transformed image. 请禁用Viewcontroller的AutoLayout属性,并使用以下值更改代码,以便能够查看转换后的图像。

[rocket setFrame:CGRectMake(50, 50, 200, 200)];
rocket.bounds = CGRectMake(200,200,200,200);
rocket.center = CGPointMake(200,200);
[UIView animateWithDuration:0.3f animations:^{
        rocket.image = UIImage(named: "rocket.png")
        rocket.frame = CGRectMake(200,200,200,200)
        rocket.bounds = CGRectMake(200,200,200,200)
        rocket.center = CGPointMake(400,400)
}];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM