【发布时间】:2014-04-02 07:20:45
【问题描述】:
我是 Objective c 的新手,所以希望这一切都有意义.. 我在 .h 文件中声明了 UIView
@property (strong, nonatomic) UIView *menuViewone;
在 .m 文件中,我在 viewdidload 中声明了 UIView
menuViewone =[[UIView alloc ]initWithFrame:CGRectMake(-400, 0, 200, 568) ];
[menuViewone setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:menuViewone];
并在Button方法中设置视图框架
- (IBAction)collectionmenutwo:(id)sender {
if (menuViewone.frame.origin.x >=0 ) {
[UIView animateKeyframesWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
menuViewone.frame=CGRectMake(-400, 100, 300, 568);
} completion:^(BOOL finished) {
}];
}
else
{
[UIView animateKeyframesWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
menuViewone.frame=CGRectMake(200, 100, 300, 568);
} completion:^(BOOL finished) {
}];
}}
现在我想在这个 UIView 中声明按钮......我如何以编程方式做到这一点?
【问题讨论】:
标签: ios iphone objective-c uiview