这是一个小型库,包含我日常使用的一些辅助工具,以节省代码。
示例
而不是
CGRect frame = view.frame;
frame.size.width -= 20;
view.frame = frame;
您可以编写
view.frame.width -= 20;
UIImage.width
和 UIImage.height
UIView
:
CGFloat x
CGFloat y
CGFloat width
CGFloat height
CGFloat boundsX
CGFloat boundsY
CGFloat boundsWidth
CGFloat boundsHeight
CGPoint origin
CGPoint boundsOrigin
CGSize size
CGSize boundsSize
UIButton
UIImage *image
UIImage *backgroundImage
UIImage *selectedImage
UIImage *selectedBackgroundImage
NSString *title
NSString *selectedTitle
BOOL IsRetinaScreen();
BOOL IsRetina4Screen();
CGFloat iOSVersion();
BOOL iOSVersionIsAtLeast(CGFloat version);
BOOL iOSVersionIsAtMost(CGFloat version);
BOOL iOSVersionIsGreatherThan(CGFloat version);
BOOL iOSVersionIsLessThan(CGFloat version);
通知辅助工具 (我尝试使通知尽可能简单灵活,因此有许多可选参数)
On(NSString *event[, id object], NotificationBlock block);
On(NSString *event[, id object], id target, NSString *selectorName);
Off(NSString *event[, NotificationBlock block]);
Off(NSString *event[, id target, NSString *selectorName]);
Trigger([id sender,] NSString *event [, NSDictionary *userInfo]);
On
方法,它原本可以写成:[[NSNotificationCenter defaultCenter] addObserver:target
selector:NSSelectorFromString(selectorName)
name:event
object:object];
或者您也可以用块代替目标和选择器...