@interface UIScreen (addtion)
/**
獲取屏幕寬度
*/
- (CGFloat)pq_screenWidth;
/**
獲取屏幕高度
*/
- (CGFloat)pq_screenHeight;
/**
獲取屏幕分辨率
*/
- (CGFloat)pq_screenScale;
@end
pragma mark - NSBundle(addtion)
@interface NSBundle(addtion)
/**
獲取當(dāng)前appname
@return appname
*/
- (NSString *)pq_appName;
/**
獲取當(dāng)前app版本
@return app版本
*/
- (NSString *)pq_currentAppVersion;
/**
獲取build版本
@return appBuild版本
*/
- (NSString *)pq_buildAppVersion;
@end
pragma mark - NSDate (addtion)
@interface NSDate(addtion)
/**
獲取當(dāng)前時間戳(since GMT 1970-1-1)
@return 當(dāng)前距GMT時間的時間差 second
*/
- (NSInteger)pq_currentTimeStamp;
/**
獲取當(dāng)前的時間格式
@param format 格式如 @"yyyy-MM-dd HH:mm:ss "
@return 返回時間字符
*/
- (NSString )pq_currentDateStringWithFormat:(NSString )format;
/
獲取當(dāng)前的時區(qū)
@return 當(dāng)前的時區(qū)
*/
- (NSInteger)pq_currentTimeZone;
@end
@implementation UIScreen(addtion)
-
(CGFloat)pq_screenWidth {
return [UIScreen mainScreen].bounds.size.width;
}
(CGFloat)pq_screenHeight {
return [UIScreen mainScreen].bounds.size.height;
}(CGFloat)pq_screenScale {
return [UIScreen mainScreen].scale;
}
@end
@implementation NSBundle(addtion)
(NSString *)pq_appName {
return [NSBundle mainBundle].infoDictionary[@"CFBundleDisplayName"];
}(NSString *)pq_currentAppVersion {
return [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
}-
(NSString *)pq_buildAppVersion {
return [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
}
@end
@implementation NSDate(addtion)
-
(NSInteger)pq_currentTimeStamp {
return [[NSDate date] timeIntervalSince1970];
} (NSString *)pq_currentDateStringWithFormat:(NSString *)format {
NSDate *date = [NSDate date];
NSDateFormatter *forMatter = [[NSDateFormatter alloc] init];
[forMatter setDateFormat:format];
NSString *dateStr = [forMatter stringFromDate:date];
return dateStr;
}-
(NSInteger)pq_currentTimeZone {
return [NSTimeZone localTimeZone].secondsFromGMT/3600;
}
@end