实用工具方法、类别、宏和辅助程序,以提高您的 iOS 开发速度。
只需将 pod ‘BTUtils’
添加到您的 Podfile 中或将类文件拖放到您的项目中。
BTUtils 全局支持 ARC。
iOS 5+
RGB(r, g, b)
带有 alpha 的原生前 changedRed 方法的一行内部控制色
RGBA(r, g, b, a)
带有 alpha 的原生前 changedRed 方法的单行ctlColor
SYSTEM_VERSION_GREATER_OR_EQUAL_TO(v)
检查系统版本是否大于等于特定字符串版本。
RADIANS_TO_DEGREES(radians)
将弧度转换为角度。
DEGREES_TO_RADIANS(angle)
将角度转换为弧度。
IS_NOT_NULL(dictionary, key)
检查给定的键是否在给定的字典中。
IS_ARRAY(array)
检查给定的数组是否为数组。
IS_DICTIONARY(dict)
检查给定的字典是否为字典。
IS_EMPTY(string)
检查给定的字符串是否为空或空长度。
BSLog(format, …)
是标准 NSLog 的替换者,具有更精美的控制台输
+ (NSString *)OSVersion;
返回操作系统的当前版本。
+ (NSString *)appVersion;
使用键 'CFBundleShortVersionString' 返回应用程序版本字符串。
+ (NSString *)appBuild;
使用键 'CFBundleVersion' 返回应用程序构建字符串。
+ (NSString *)appName;
使用键 'CFBundleDisplayName' 返回应用程序名称字符串。
+ (NSString *)deviceModel;
返回设备型号。
+ (CGSize)screenSize;
返回屏幕尺寸。
+ (UIInterfaceOrientation)orientation;
返回界面方向。
+ (BOOL)isPad;
当 UIUserInterfaceIdiom 是 Pad 时返回 YES。
+ (BOOL)isPhone;
当 UIUserInterfaceIdiom 是 Phone 时返回 YES。
+ (PhoneScreenSize)phoneScreenSize;
返回 iPhone 屏幕尺寸。
+ (BOOL)isPhone4Inch; -deprecated
如果设备是手机且 4 英寸(即 iPhone 5/5s/5c),则返回 YES。
+ (BOOL)isRetina;
如果设备屏幕具有 Retina 分辨率,则返回 YES。
+ (NSString *)CFUUID;
返回指定的 CFUUID 对象的字符串表示。
+ (void)showNetworkLoader:(BOOL)show;
开关网络活动指示器。
+ (NSString *)resourcePath:(NSString *)name;
返回选中文件名的资源路径。
+ (NSString *)appStoreLinkForAppId:(NSString *)appId;
返回选中 appId 的 App Store 链接。
+ (NSString *)urlEncodedString:(NSString *)string;
URL 编码字符串。
+ (NSArray *)traceCallStack;
从您要跟踪堆栈的类中调用此私有实例方法。
+ (NSString *)traceCallClassWithDetails:(BOOL)withDetails;
从您要跟踪类的类中调用此私有实例方法。
+ (NSArray *)propertyNamesForObject:(id)object;
返回类属性名称。
+ (UIImage *)imageNamed:(NSString *)name; -deprecated
从文件系统中返回未缓存的图片。
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size;
为选择的颜色和大生成新的UIImage。
+ (UIImage *)captureView:(UIView *)view;
捕获选定的视图的屏幕。
+ (UIImage *)captureFrame:(CGRect)frame inView:(UIView *)view;
捕获选定视图内的帧。
- (NSString *)stringByDecodingHTMLEntities;
使用GTM解码所有HTML实体。
- (NSString *)stringByEncodingHTMLEntities;
使用GTM编码所有HTML实体。
- (NSString *)stringByConvertingHTMLToPlainText;
从HTML字符串中删除HTML标签以获得纯文本。
- (NSUInteger)indexOf:(NSString *)character;
获取字符串中字符的索引。
- (BOOL)containsString:(NSString *)substring;
如果子串是字符串的一部分,返回YES。
- (NSString *)urlEncode;
返回url编码的字符串。
- (NSString *)trim;
从给定字符串中剪除前导和尾部空格和换行字符。
- (NSData *)dataFromBase64String;
创建一个包含base64解码表示的NSData对象。
- (NSString *)hexValue;
返回字符串的UTF8十六进制表示。
- (NSString *)addUrlParam:(NSString *)param withValue:(NSString *)value;
以正确格式向现有URL添加带值的新参数。
- (NSString *)MD5;
MD5加密散列。
- (NSString *)SHA1;
SHA1加密散列。
- (CGSize)textSizeWithFont:(UIFont *)font fieldSize:(CGSize)size;
返回预测字段中特定文本的文本边界大小。
- (BOOL)isEmailValid;
返回电子邮件是否有效的BOOL。
- (BOOL)isURLValid;
返回URL是否有效的BOOL。
- (NSString *)base64EncodedString;
创建一个包含接收者数据的base 64编码的NSString对象。换行在64个字符处中断。
- (UIImage *)imageWithBorderWidth:(CGFloat)borderWidth inColor:(UIColor *)borderColor
返回具有圆角和边框颜色的图片。
- (UIImage *)imageWithRoundedCornersRadius:(float)radius andBorderColor:(UIColor *)borderColor;
返回具有圆角和边框颜色的图片。
- (UIImage *)imageByScalingAndCroppingForSize:(CGSize)targetSize;
返回目标大小缩放的图片。
- (UIImage *)imageByApplyingAlpha:(CGFloat)alpha;
返回具有给定不透明度的图片。
- (UIImage *)imageWithShadowSize:(CGFloat)size shadowColor:(UIColor *)color;
返回带有阴影的给定图片。
- (UIImage *)imageTintedWithColor:(UIColor *)tintColor;
返回具有给定tintColor着色的图片。
- (void)maskRoundCorners:(UIRectCorner)corners radius:(CGFloat)radius;
返回具有圆角的遮罩视图。
- (void)pulseEffectToSize:(CGFloat)size duration:(CGFloat)duration;
向视图添加脉动动画。
- (void)spinWithDuration:(CFTimeInterval)duration angle:(CGFloat)angle;
旋转视图的层。
- (void)dashedLineWithColor:(UIColor *)color;
返回虚线线/视图。
- (CGSize)size;
获取帧大小。
- (void)setSize:(CGSize)size;
设置帧大小。
- (CGFloat)width;
获取帧宽度。
- (void)setWidth:(CGFloat)width;
设置帧宽度。
- (CGFloat)height;
获取帧高度。
- (void)setHeight:(CGFloat)height;
设置帧高度。
- (CGFloat)x;
获取帧x原点。
- (void)setX:(CGFloat)originX;
设置帧x原点。
- (CGFloat)y;
获取帧y原点。
- (void)setY:(CGFloat)originY;
设置帧y原点。
static inline CGFloat CGHorizontalCenterInParent(CGRect frame, CGFloat childWidth)
返回给定子宽度在父帧中的水平居中华坐标。
static inline CGFloat CGVerticalCenterInParent(CGRect frame, CGFloat childHeight)
返回给定子高度在父帧中的垂直居中y坐标。
static inline CGRect CGCenterInParent(CGRect parent, CGFloat childWidth, CGFloat childHeight)
返回给定子宽度和高度在父帧中的居中帧。
- (NSArray *)reversedArray;
反转数组值。
- (NSArray *)uniqueObjects;
返回数组中唯一的对象。
返回给定十六进制颜色格式的颜色。
- (void)showTabBarAnimated:(BOOL)animated;
显示带有/不带动画的tabBar。
- (void)hideTabBarAnimated:(BOOL)animated;
隐藏带有/不带动画的tabBar。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- (BOOL)shouldAutorotate
- (NSUInteger)supportedInterfaceOrientations
- (BOOL)shouldAutorotate
- (NSUInteger)supportedInterfaceOrientations
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation