首页 > 其他 > 详细

获取屏幕宽高和系统色系

时间:2015-06-20 00:12:30      阅读:367      评论:0      收藏:0      [点我收藏+]

ios7下获取的屏幕高度
    [UIScreen mainScreen].bounds.size.height=1024
    ios8下获取的屏幕高度
    [UIScreen mainScreen].bounds.size.height=768
   

   if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
        height =[UIScreen mainScreen].bounds.size.height;
    }else{
        height =[UIScreen mainScreen].bounds.size.width;
    }

常用宏···

//获得当前屏幕宽高点数(非像素)
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
#define kScreenWidth  [UIScreen mainScreen].bounds.size.width

//ios7系统色系
#define kGreenColor     [UIColor colorWithHexString:@"#44DB5E"];
#define kRedColor       [UIColor colorWithHexString:@"#FF3824"];
#define kGrayColor      [UIColor colorWithHexString:@"#8E8E93"];
#define kYellowColor    [UIColor colorWithHexString:@"#FFCD00"];
#define kSkyBlueColor   [UIColor colorWithHexString:@"#54C7FC"];
#define kOrangeColor    [UIColor colorWithHexString:@"#FF9600"];
#define kGreenColor     [UIColor colorWithHexString:@"#44DB5E"];
#define kPinkColor      [UIColor colorWithHexString:@"#FF2851"];
#define KBlueColor      [UIColor colorWithHexString:@"#0076FF"];

//判断iphone6
#define kiPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
//判断iphone6+
#define kiPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
//判断ipad
#define kiPad ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

 

系统色系需要UIColor扩展支持

#import <UIKit/UIKit.h>

#define RGBA_COLOR(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A]
#define RGB_COLOR(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f]

@interface UIColor (Hex)

+ (UIColor *)colorWithHexString:(NSString *)color;

//从十六进制字符串获取颜色,
//color:支持@“#123456”、 @“0X123456”、 @“123456”三种格式
+ (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha;

@end

获取屏幕宽高和系统色系

原文:http://www.cnblogs.com/zym888/p/4589949.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!