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
{ | |
"linters": { | |
"spelling": { | |
"type": "spelling" | |
}, | |
"generated": { | |
"type": "generated" | |
}, | |
"merge-conflict": { | |
"type": "merge-conflict" |
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
- (UIViewController *)topViewController{ | |
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController]; | |
} | |
- (UIViewController *)topViewController:(UIViewController *)rootViewController | |
{ | |
if (rootViewController.presentedViewController == nil) { | |
return rootViewController; | |
} | |
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
UIImage *image; //The image would be save | |
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; | |
[library writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)image.imageOrientation completionBlock:^(NSURL *assetURL, NSError *error) { | |
if (!error) { | |
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) { | |
ALAssetRepresentation *defaultRep = [asset defaultRepresentation]; | |
NSString *fileName = [defaultRep filename]; | |
} failureBlock:^(NSError *error) { | |
}]; | |
} |
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
127.0.0.1 t.sina.com.cn | |
127.0.0.1 weibo.com | |
127.0.0.1 zhihu.com | |
127.0.0.1 douban.com | |
127.0.0.1 cnbeta.com | |
127.0.0.1 renren.com | |
127.0.0.1 xiaonei.com | |
127.0.0.1 zhibo8.cc | |
127.0.0.1 zhibo8.com | |
127.0.0.1 36kr.com |
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
UIWindow *window = [UIApplication sharedApplication].keyWindow; | |
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { | |
UIGraphicsBeginImageContextWithOptions(window.bounds.size, NO, [UIScreen mainScreen].scale); | |
} | |
else { | |
UIGraphicsBeginImageContext(window.bounds.size); | |
} | |
if ([window respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) { | |
[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; | |
} |
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)drawRect:(CGRect)rect { | |
[super drawRect:rect]; | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); | |
// Draw them with a 2.0 stroke width so they are a bit more visible. | |
CGContextSetLineWidth(context, 2.0); | |
CGContextMoveToPoint(context, 0,0); //start at this point |
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
/* | |
* attention: before this you should have a AVAudioPlayerDelegate | |
*/ | |
//init | |
NSString *audioPath = [[NSBundle mainBundle]pathForResource:@"audio" ofType:@"mp3"]; | |
NSURL *audioURL = [NSURL fileURLWithPath:audioPath]; | |
NSError *error; | |
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:&error]; | |
if (error) { |
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
#pragma mark - Log | |
//debug log | |
#ifdef DEBUG | |
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
# define DLogRect(rect) DLog(@"%s x=%f, y=%f, w=%f, h=%f", #rect, rect.origin.x, rect.origin.y,rect.size.width, rect.size.height) | |
# define DLogPoint(pt) DLog(@"%s x=%f, y=%f", #pt, pt.x, pt.y) | |
# define DLogSize(size) DLog(@"%s w=%f, h=%f", #size, size.width, size.height) | |
# define DLogColor(_COLOR) DLog(@"%s h=%f, s=%f, v=%f", #_COLOR, _COLOR.hue, _COLOR.saturation, _COLOR.value) |