【发布时间】:2015-11-25 02:56:54
【问题描述】:
我在主 ViewController 中使用一个视图,并希望通过单击按钮将其移动到新位置。 我已经尝试过使用不同的方法...
.h 文件
@property (nonatomic, strong) IBOutlet UIView *UIview3;
.m 文件
@synthesize UIview3;
我已经实现了以下方法。
方法:1
CGRect f = self.UIview3.frame;
f.origin.x = 28; // new x
f.origin.y = 74; // new y
self.UIview3.frame = f;
方法:2
UIView *newview = [[UIView alloc]initWithFrame:
CGRectMake(28, 74, 261, 119)];
[self.UIview3 addSubview:newview];
其他方法(不在此工作)
UIview3.frame = CGRectMake(28, 231, 261, 119);
UIview3.center = CGPointMake( 28,74);
[_UIview3 setFrame:CGRectMake(28, 74, 261, 119)];
[_UIview3 setFrame:CGPointMake( 28,74)];
[self.UIview3 setCenter:CGPointMake(28, 74)];
有人帮忙吗?提前致谢。 苏哈诺尔
【问题讨论】:
-
你可以使用 UIAnimation 来获得你需要的效果。
-
我已经尝试过了,但我需要暂停视图,直到再次按下按钮。 [UIView animateWithDuration:0.9 动画:^{ UIview3.frame = CGRectMake(28, 74, 261, 119); // 最后一帧 }];-> 你能帮我吗?请@你好
-
你在哪里写的动画块?
-
检查您是否忘记在
.xib或storyboard设置插座。
标签: ios objective-c iphone uiview