首页 > 其他 > 详细

将cell转化为全屏横屏显示

时间:2015-12-07 20:50:58      阅读:155      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!