Common macro definitions for iOS development

Source: Internet
Author: User

#define NAVIGATIONBAR_HEIGHT 44//navigation bar height

#define SCREEN_WIDTH ([UIScreen mainscreen].bounds.size.width)//Dynamic acquisition of the width of the physical device

#define Screen_height ([UIScreen mainscreen].bounds.size.height)//dynamic acquisition of the height of the physical device

#define SAFE_RELEASE (x) [x RELEASE]; x=Nil//safe release

#define Ios_version [[[Uidevice Currentdevice] systemversion] floatvalue]//Get current device system version

#define CURRENTLANGUAGE ([[Nslocale preferredlanguages] objectatindex:0])//Get the current device language

#define Background_color [Uicolor colorwithred:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]//Background color

#define SAFE_DELETE (P) if (p) {[P release], p = Nil;} Safely delete objects

#define COLOR (R, G, B, A) [Uicolor colorwithred:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]//Colour values with RGBA

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

#define Clearcolor [Uicolor Clearcolor]//clear background color

#define Alertcontent (content) Uialertview *alert = [[Uialertview alloc] initwithtitle:@ "hint" \

Message:content \

Delegate:nil \

cancelbuttontitle:@ "OK" \

Otherbuttontitles:nil]; \

[Alert show]; \

Warning Box content prompt

#define Degreestoradian (x) (M_PI * (x)/180.0)//angle to radians

#define Radiantodegrees (Radian) (radian*180.0)/(M_PI)//Radian Turn angle

The following three macros are used to determine the device type

#define Isretina ([UIScreen instancesrespondtoselector: @selector (currentmode)]? Cgsizeequaltosize (Cgsizemake (640, 960), [[UIScreen Mainscreen] currentmode].size): NO)

#define IPHONE5 ([UIScreen instancesrespondtoselector: @selector (currentmode)]? Cgsizeequaltosize (Cgsizemake (640, 1136), [[UIScreen Mainscreen] currentmode].size): NO)

#define ISPAD (ui_user_interface_idiom () = = Uiuserinterfaceidiompad)

Common macro definitions for iOS development

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.