获取屏幕宽高和系统色系

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

时间: 2024-12-16 06:13:44

获取屏幕宽高和系统色系的相关文章

android获取屏幕宽高与获取控件宽高

获取屏幕宽高 // 获取屏幕宽高(方法1) int screenWidth = getWindowManager().getDefaultDisplay().getWidth(); // 屏幕宽(像素,如:480px) int screenHeight = getWindowManager().getDefaultDisplay().getHeight(); // 屏幕高(像素,如:800p) Log.e(TAG + " getDefaultDisplay", "screen

android 获取屏幕宽高 和 获取控件坐标

一.获取屏幕宽高: (1). WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); int height = wm.getDefaultDisplay().getHeight(); (2). WindowManager wm = this.getWindowManager(); int width = wm

android获取屏幕宽高工具类

import java.lang.reflect.Field; import android.app.Activity; import android.content.Context; import android.graphics.Point; import android.util.DisplayMetrics; import android.view.Display; import android.view.Window; import android.view.WindowManager

安卓获取屏幕宽高/分辨率相关信息的方式

private void getSystemInfo() { //第一种方式获取屏幕的像素宽高在Activity里面可使用 //DisplayMetrics metric = new DisplayMetrics(); //Activity.getWindowManager().getDefaultDisplay().getMetrics(metric); //第二种方式获取屏幕的像素宽高 //获取屏幕的像素高度PIX screenHeight = getResources().getDispl

获取屏幕宽高width(),outerWidth,innerWidth,documentElement.clientWidth, body.clientWidth的区别

基本介绍 $(window).width()与$(window).height() $(window).width()与$(window).height():获得的是屏幕可视区域的宽高,不包括滚动条与工具条. $(window).width() = width + padding $(window).height() = height + padding document.documentElement.clientWidth与document.documentElement.clientHei

获取屏幕宽高

屏幕分辨率的高: window.screen.height屏幕分辨率的宽: window.screen.width 注解:电脑屏幕的分辨率(包括导航栏和滚动条) 屏幕可用区域的宽: var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 屏幕可见区域的高 var h=window.innerHeight || document.documentElement.cli

Android 获取屏幕宽高

WindowManager m = getActivity().getWindowManager(); DisplayMetrics metric = new DisplayMetrics(); m.getDefaultDisplay().getMetrics(metric); int width = metric.widthPixels; // 屏幕宽度(像素) int height = metric.heightPixels; // 屏幕高度(像素) float density = metr

Android 获取屏幕宽高值

时间:2016年3月7日16:14:52 note:单位为像素. 三个方法中都是根据Display来进行测量. //方法一: WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); System.out

Javascript之获取屏幕宽高

<head> <title> new document </title> <meta name="generator" content="editplus" charset="utf-8"/> </head> <script language="javascript"> document.write("screen.availHeight:&qu