• iOS学习之自定义视图时,在屏幕发生旋转时触发重新布局方法


    如果要对自定义的视图在屏幕旋转时重新布局,则在自定义视图中定义以下触发方法:

    -(void)layoutSubviews {
        [super layoutSubviews];
        //1.获取到屏幕旋转的方向
        UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
        //2.根据屏幕旋转方向布局子视图
        switch (orientation) {
                //竖直方向
            case UIDeviceOrientationPortrait:
                //倒立
            case UIDeviceOrientationPortraitUpsideDown:
            {
                CGRect fram = self.loginButton.frame;
                fram.origin.x = kMarginTop_LoginButton;
                fram.origin.y = kMarginTop_LoginButton;
                self.loginButton.frame = fram;
            }
                break;
                
                //右横屏
            case UIDeviceOrientationLandscapeRight:
                //左横屏
            case UIDeviceOrientationLandscapeLeft:
            {
                CGRect fram = self.loginButton.frame;
                fram.origin.x = kMarginLeft_LoginButton_Landscape;
                fram.origin.y = kMarginTop_DescripLabel;
                self.loginButton.frame = fram;
            }
                break;
                
            default:
                break;
        }
    }
  • 相关阅读:
    时序图
    用例图
    欢迎界面(闪屏)
    WBS
    闲来听书
    软件团队的模式
    结对编程
    在个人项目中,找bug,审核代码.
    时序图
    部分功能的实现
  • 原文地址:https://www.cnblogs.com/ErosLii/p/4471112.html
Copyright © 2020-2023  润新知