改变UIImageView的位置 [英] change position of the UIImageView

查看:219
本文介绍了改变UIImageView的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为UIImageView进行简单的位置更改。让我们说当前坐标是x:20和y:30

How can I do a simple position changing for UIImageView. Lets say that current coordinates are x: 20 and y:30

我想把它移到x:100和y:100。

I want to move it to x:100 and y:100.

是否可以做动作动画?

推荐答案

你需要改变那个的CGFrame UIImageView 喜欢这样 -

You need to change the CGFrame of that UIImageView Like so -

[imageView setFrame:CGRectMake(100,100,imageView.frame .size.width,imageView.frame.size.height)];

这改变了 uiimageview 保持高度和宽度相同,保持(100,100)。请注意,您可以使用上述代码不仅更改(x,y)位置,还可以更改视图的大小。使用下面的代码你也可以为它设置动画:)

This changes the uiimageview poistion to (100, 100) while keeping the height and width same. Note that you can use the above code to not only change the (x,y) position but also the size of the view. Using the below code you can animate it too :)

如果你想为位置变化设置动画 -

If you want to animate the position change -

[UIView animateWithDuration:0.35 
                      delay:0.0  
                    options: UIViewAnimationCurveEaseOut
                 animations:^{ 
                     [imageView setFrame:CGRectMake(100, 100, imageView.frame.size.width, imageView.frame.size.height)];
                 } 
                 completion:^(BOOL finished){
                     NSLog(@"Done!");
                 }];

这篇关于改变UIImageView的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆