码迷,mamicode.com
首页 > 其他好文 > 详细

将cell转化为全屏横屏显示

时间:2015-12-07 20:52:53      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

- (void)fullButtonAction:(UIButton *)sender{

    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;

    if ([sender.titleLabel.text isEqualToString:@"收起"]) {

        CGRect inWindowFrame = [self.lastSuperView convertRect:self.frame fromView:keyWindow];

        self.frame = inWindowFrame;

        [UIView animateWithDuration:2 animations:^{

            [self.lastSuperView addSubview:self];

            self.transform = CGAffineTransformMakeRotation(0);

            self.frame = self.lastFrame;

            [self.rootView requestLayout];

        } completion:^(BOOL finished) {

            [self.fullScreenButton setTitle:@"全屏" forState:UIControlStateNormal];

        }];

        return;

    }

    self.lastSuperView = self.superview;

    self.lastFrame = self.frame;

    [keyWindow addSubview:self];

    [keyWindow bringSubviewToFront:self];

}

 

- (void)didMoveToSuperview{

    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;

    if (self.superview == keyWindow) {

        CGRect inWindowFrame = [self.lastSuperView convertRect:self.frame toView:keyWindow];

        self.frame = inWindowFrame;

        [UIView animateWithDuration:2 animations:^{

            CGSize windowSize = [UIScreen mainScreen].bounds.size;

            self.frame = CGRectMake(0, 0, windowSize.height, windowSize.width);

            self.transform = CGAffineTransformMakeRotation(M_PI_2);

            self.center = CGPointMake(windowSize.width/2, windowSize.height/2);

            [self.rootView requestLayout];

        } completion:^(BOOL finished) {

            [self.fullScreenButton setTitle:@"收起" forState:UIControlStateNormal];

        }];

    }  

}

 

fullButtonAction:为cell中全屏button响应

转场动画用transform来实现

didMoveToSuperview方法是对象被添加到某个view中后回调方法

将cell转化为全屏横屏显示

标签:

原文地址:http://www.cnblogs.com/nhwly/p/5027253.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!