ios之开发中使用频率很高的宏定义-提高设备屏幕适配以及开发效率
2014-11-24 18:37
531 查看
// log #define APP_Log(...) NSLog(__VA_ARGS__) // assert #ifdef ENABLE_ASSERT_STOP #define APP_ASSERT_STOP {LogRed(@"APP_ASSERT_STOP"); NSAssert1(NO, @" \n\n\n===== APP Assert. =====\n%s\n\n\n", __PRETTY_FUNCTION__);} #define APP_ASSERT(condition) {NSAssert(condition, @" ! Assert");} #else #define APP_ASSERT_STOP do {} while (0); #define APP_ASSERT(condition) do {} while (0); #endif ///////////////////////////////////////////////////////////////////////////////////// #pragma mark - Redefine #define ApplicationDelegate ((BubblyAppDelegate *)[[UIApplication sharedApplication] delegate]) #define UserDefaults [NSUserDefaults standardUserDefaults] #define SharedApplication [UIApplication sharedApplication] #define Bundle [NSBundle mainBundle] #define MainScreen [UIScreen mainScreen] #define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES #define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO #define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x #define SelfNavBar self.navigationController.navigationBar #define SelfTabBar self.tabBarController.tabBar #define SelfNavBarHeight self.navigationController.navigationBar.bounds.size.height #define SelfTabBarHeight self.tabBarController.tabBar.bounds.size.height #define ScreenRect [[UIScreen mainScreen] bounds] #define ScreenWidth [[UIScreen mainScreen] bounds].size.width #define ScreenHeight [[UIScreen mainScreen] bounds].size.height #define TouchHeightDefault 44 #define TouchHeightSmall 32 #define ViewWidth(v) v.frame.size.width #define ViewHeight(v) v.frame.size.height #define ViewX(v) v.frame.origin.x #define ViewY(v) v.frame.origin.y #define SelfViewHeight self.view.bounds.size.height #define RectX(f) f.origin.x #define RectY(f) f.origin.y #define RectWidth(f) f.size.width #define RectHeight(f) f.size.height #define RectSetWidth(f, w) CGRectMake(RectX(f), RectY(f), w, RectHeight(f)) #define RectSetHeight(f, h) CGRectMake(RectX(f), RectY(f), RectWidth(f), h) #define RectSetX(f, x) CGRectMake(x, RectY(f), RectWidth(f), RectHeight(f)) #define RectSetY(f, y) CGRectMake(RectX(f), y, RectWidth(f), RectHeight(f)) #define RectSetSize(f, w, h) CGRectMake(RectX(f), RectY(f), w, h) #define RectSetOrigin(f, x, y) CGRectMake(x, y, RectWidth(f), RectHeight(f)) #define Rect(x, y, w, h) CGRectMake(x, y, w, h) #define DATE_COMPONENTS NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit #define TIME_COMPONENTS NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit #define FlushPool(p) [p drain]; p = [[NSAutoreleasePool alloc] init] #define RGB(r, g, b) [UIColor colorWithRed:(r)/255.f green:(g)/255.f blue:(b)/255.f alpha:1.f] #define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a] #define StatusBarHeight [UIApplication sharedApplication].statusBarFrame.size.height #define SelfDefaultToolbarHeight self.navigationController.navigationBar.frame.size.height #define IOSVersion [[[UIDevice currentDevice] systemVersion] floatValue] #define IsiOS7Later !(IOSVersion < 7.0) #define Size(w, h) CGSizeMake(w, h) #define Point(x, y) CGPointMake(x, y) #define TabBarHeight 49.0f #define NaviBarHeight 44.0f #define HeightFor4InchScreen 568.0f #define HeightFor3p5InchScreen 480.0f #define ViewCtrlTopBarHeight (IsiOS7Later ? (NaviBarHeight + StatusBarHeight) : NaviBarHeight) #define IsUseIOS7SystemSwipeGoBack (IsiOS7Later ? YES : NO) ////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - app define #define RGB_AppWhite RGB(252.0f, 252.0f, 252.0f) #define RGB_TextLightGray RGB(200.0f, 200.0f, 200.0f) #define RGB_TextMidLightGray RGB(127.0f, 127.0f, 127.0f) #define RGB_TextDarkGray RGB(100.0f, 100.0f, 100.0f) #define RGB_TextLightDark RGB(50.0f, 50.0f, 50.0f) #define RGB_TextDark RGB(10.0f, 10.0f, 10.0f) #define RGB_TextAppOrange RGB(224.0f, 83.0f, 51.0f) #define SIZE_TextSmall 10.0f #define SIZE_TextContentNormal 13.0f #define SIZE_TextTitleMini 15.0f #define SIZE_TextTitleNormal 17.0f #define SIZE_TextLarge 16.0f #define SIZE_TextHuge 18.0f
ios屏幕适配:
// 是否4英寸屏幕 + (BOOL)is4InchScreen { static BOOL bIs4Inch = NO; static BOOL bIsGetValue = NO; if (!bIsGetValue) { CGRect rcAppFrame = [UIScreen mainScreen].bounds; bIs4Inch = (rcAppFrame.size.height == 568.0f); bIsGetValue = YES; }else{} return bIs4Inch; } // label设置最小字体大小 + (void)label:(UILabel *)label setMiniFontSize:(CGFloat)fMiniSize forNumberOfLines:(NSInteger)iLines { if (label) { label.adjustsFontSizeToFitWidth = YES; label.minimumScaleFactor = fMiniSize/label.font.pointSize; if ((iLines != 1) && (IOSVersion < 7.0f)) { label.adjustsLetterSpacingToFitWidth = YES; }else{} }else{} }
相关文章推荐
- iOS开发中使用宏定义提高开发效率 以及配合Compiler Flags写出高质量的代码
- iOS开发中使用宏定义提高开发效率
- iOS开发中使用宏定义提高开发效率
- iOS开发中使用宏定义提高开发效率
- iOS开发中使用宏定义提高开发效率
- iOS开发中使用宏定义提高开发效率
- iOS应用开发中使用Auto Layout来适配不同屏幕尺寸
- iOS开发中使用平率很高的宏定义
- iOS开发 -- 使用facebook的chisel来提高调试效率
- 正确使用iOS常量(const)、enum以及宏(#define)在iOS开发中请尽量多使用const、enum来代替宏定义(#define);随着项目工程的逐渐增大,过多的宏定义还可能影响项目的编译
- 【iOS开发-41】简单动画的万能代码——beginAnimations和commitAnimation使用频率很高
- iOS项目开发实战——如何使用Autoresizing进行屏幕适配
- iOS开发-学会使用代码块,提高你的开发效率
- IOS 特定于设备的开发:使用加速器启动屏幕上的对象
- iOS开发提高效率之:使用CocoaPods管理依赖库
- 【iOS-Cocos2d游戏开发之十一】使用Box2d物理系统以及在cocos2d框架添加Box2d物理系统lib包的方法
- 【Android游戏开发二十一】Android os设备谎言分辨率的解决方案!以及简单阐述游戏引擎如何使用!
- iphone开发常用开源库1----常用的几个提高iOS开发效率的开源类库及工具
- 几个提高iOS开发效率的开源类库及工具
- 【iOS-Cocos2d游戏开发之八】开启高清(960*640)模式问题与解答、图片适配以及设置iphone横竖屏