zoukankan      html  css  js  c++  java
  • QQ空间HD(4)-设置左侧菜单栏属性

    DJHomeViewController.m

    #import "DJHomeViewController.h"
    #import "DJMenuView.h"
    
    
    const CGFloat screenW = 768;
    const CGFloat screenH = 1024;
    
    @interface DJHomeViewController ()
    
    @property (nonatomic,weak) DJMenuView *menuView;
    
    @end
    
    @implementation DJHomeViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        DJMenuView *menuView = [[DJMenuView alloc] init];
        
        [self.view addSubview:menuView];
        self.menuView = menuView;
        
        // 根据屏幕方向设置menu属性
        [self willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
        
        
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    
    /** 当屏幕方向将会发生改变时调用此方法 */
    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    
        if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
            NSLog(@"当前已旋转为横屏");
            self.menuView.width = 150;
            self.menuView.height = screenW;
            
        } else {
            NSLog(@"当前已旋转为竖屏");
            self.menuView.width = 80;
            self.menuView.height = screenH;
        }
    
    }
    
    
    @end

    横屏:

    竖屏:

  • 相关阅读:
    SQL Server 配置管理器不见了
    SQL常用函数使用
    数据库优化
    关于百度地图js api的getCurrentPosition定位不准确的解决方法
    uni-app中使用外部字体
    不定高度,元素垂直居中
    css实现的鼠标悬浮提示
    导入
    下载
    百度地图在地图上标点显示数字
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/6213097.html
Copyright © 2011-2022 走看看