This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface UIView (EX) | |
@property (nonatomic, strong) UIView *bottomLine; // <##> | |
- (void)as_addBottomLine; | |
- (void)as_addBottomLineWithLeftOffset:(CGFloat)leftOffset rightOffset:(CGFloat)rightOffset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static CGSize const kViewSize = {19, 19}; | |
- (void)layoutSubviews { | |
[super layoutSubviews]; | |
if (!CGSizeEqualToSize(self.bounds.size, [self intrinsicContentSize])) { | |
[self invalidateIntrinsicContentSize]; | |
} | |
} | |
- (CGSize)intrinsicContentSize { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSDictionary *)dictQuery { | |
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; | |
NSString *str = self.query; | |
if (str.length && [str rangeOfString:@"="].location != NSNotFound) { | |
NSArray *keyValuePairs = [str componentsSeparatedByString:@"&"]; | |
for (NSString *keyValuePair in keyValuePairs) { | |
NSArray *pair = [keyValuePair componentsSeparatedByString:@"="]; | |
// don't assume we actually got a real key=value pair. start by assuming we only got @[key] before checking count | |
NSString *paramValue = pair.count == 2 ? pair[1] : @""; | |
// CFURLCreateStringByReplacingPercentEscapesUsingEncoding may return NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSData+AES.h" | |
#import <CommonCrypto/CommonCryptor.h> | |
@implementation NSData (AES) | |
static Byte ivBuff[] = {}; // 加密向量 | |
+ (NSString *)AES256EncryptWithContent:(NSString *)content key:(NSString *)key | |
{ | |
//加密 | |
NSData *plainText = [content dataUsingEncoding:NSUTF8StringEncoding]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { //处理远程通知——应用正在运行 | |
if(application.applicationState == UIApplicationStateInactive) { | |
//用户点击通知中心的通知或报警弹窗 | |
[self processRemoteNotification:userInfo]; | |
} else if(application.applicationState == UIApplicationStateBackground) { | |
//应用在后台,不存在用户交互——只是获取数据 } else { | |
//应用已经处于激活状态——显示应用内的更新 } | |
} | |
-(void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { | |
if (self.clipsToBounds || self.hidden || (self.alpha == 0.f)) { | |
return nil; | |
} | |
UIView *view = [super hitTest:point withEvent:event]; | |
if (view) { | |
return view; | |
} | |
for (UIView *subView in self.subviews.reverseObjectEnumerator) { | |
CGPoint subPoint = [subView convertPoint:point fromView:self]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[prompt.text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, 36) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size |