UIView动画不可见

时间:2014-04-12 09:46:15

标签: ios objective-c uiview uiviewanimation

我想用动画显示MenuView

当我致电 - showSideMenu时,MenuView没有出现。

我该如何解决?

MenuView.h

#import <UIKit/UIKit.h>

@interface SettingView : UIView

@end

MenuView.m

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.frame = CGRectMake(320, 0, 240, 568);
        self.backgroundColor = [UIColor turquoiseColor];
    }
    return self;
}

MasterViewController.m

@property (nonatomic, strong) MenuView* sideMenuView;

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIBarButtonItem* menuButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showSideMenu:)];
    self.navigationItem.rightBarButtonItem = menuButton;

    self.sideMenuView = [[MenuView alloc]initWithFrame:self.view.frame];
    [self.view addSubview:self.sideMenuView];
}

- (IBAction)showSideMenu:(id)sender
{
    [UIView animateWithDuration:0.3f
                          delay:0.0f
                        options:UIViewAnimationOptionCurveEaseIn
                     animations:^{
                         self.sideMenuView.frame = CGRectMake(80, 0, 240, 568);
                     }
                     completion:^(BOOL finished) {
                     }];
}

1 个答案:

答案 0 :(得分:0)

一些事情:

  • 在showSideMenu方法中放置NSLog。它真的开火吗?
  • 您为框架设置动画。 您是否已为此视图控制器关闭AutoLayout