iOS common define macro definitions

Source: Internet
Author: User

1. Wide screen height and common size

#define SCREEN_WIDTH ([UIScreen mainscreen].bounds.size.width)
#define Screen_height ([UIScreen mainscreen].bounds.size.height)

#define Navigationbar_height 44.0f
#define Tabbar_height 49.0f
#define Statusbar_height 20.0f
#define Toolsbar_height 44.0f

2. Color conversion

RGB color conversion (16 binary->10)
#define UICOLORFROMRGB (rgbvalue) [Uicolor colorwithred: ((float) ((Rgbvalue & 0xFF0000) >>))/255.0 Green: (( float) ((Rgbvalue & 0xff00) >> 8)/255.0 Blue: ((float) (Rgbvalue & 0xFF))/255.0 alpha:1.0]

Color settings with RGBA
#define RGBA (r,g,b,a) [Uicolor colorwithred: (r)/255.0f Green: (g)/255.0f Blue: (b)/255.0f Alpha: (a)]
#define RGB (r,g,b) RGBA (r,g,b,1.0f)

3. Notice

#define POST_NOTIFY (__name, __obj, __info) [[Nsnotificationcenter Defaultcenter] Postnotificationname:__name object:_ _obj Userinfo:__info];

#define LISTEN_NOTIFY (__name, __observer, __selector) [[Nsnotificationcenter Defaultcenter] Addobserver:__observer Selector:__selector Name:__name Object:nil];

#define REMOVE_NOTIFY (__observer) [[Nsnotificationcenter Defaultcenter] removeobserver:__observer];

4. System version

#define IOS8 [[[Uidevice Currentdevice] systemversion] floatvalue] >= 8.0? 1:0

5. URL with parameters

#define URL (__type, __record_id, __msg_id) [NSString stringwithformat:@ "Http://192.1.1.1:8000/?type=%ld&record_ Id=%ld&msg_id=%ld ", __type,__record_id,__msg_id]

iOS common define macro definitions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.