获取当前的屏幕尺寸;获取当前时间/时区;获取版本

@interface UIScreen (addtion)

/**
获取屏幕宽度
*/

  • (CGFloat)pq_screenWidth;

/**
获取屏幕高度
*/

  • (CGFloat)pq_screenHeight;

/**
获取屏幕分辨率
*/

  • (CGFloat)pq_screenScale;

@end

pragma mark - NSBundle(addtion)

@interface NSBundle(addtion)

/**
获取当前appname

@return appname
*/

  • (NSString *)pq_appName;

/**
获取当前app版本

@return app版本
*/

  • (NSString *)pq_currentAppVersion;

/**
获取build版本

@return appBuild版本
*/

  • (NSString *)pq_buildAppVersion;
    @end

pragma mark - NSDate (addtion)

@interface NSDate(addtion)

/**
获取当前时间戳(since GMT 1970-1-1)

@return 当前距GMT时间的时间差 second
*/

  • (NSInteger)pq_currentTimeStamp;

/**
获取当前的时间格式

@param format 格式如 @"yyyy-MM-dd HH:mm:ss "
@return 返回时间字符
*/

  • (NSString )pq_currentDateStringWithFormat:(NSString )format;
    /

    获取当前的时区

@return 当前的时区
*/

  • (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

你可能感兴趣的:(获取当前的屏幕尺寸;获取当前时间/时区;获取版本)