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
# xcode-build-bump.sh | |
# @desc Auto-increment the build number every time the project is run. | |
# @usage | |
# 1. Select: your Target in Xcode | |
# 2. Select: Build Phases Tab | |
# 3. Select: Add Build Phase -> Add Run Script | |
# 4. Paste code below in to new "Run Script" section | |
# 5. Drag the "Run Script" below "Link Binaries With Libraries" | |
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0) |
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 DateFlowLayout : UICollectionViewFlowLayout | |
@end |
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
if([tableview respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)]) { | |
tableview.cellLayoutMarginsFollowReadableWidth = NO; | |
} |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
CAShapeLayer *maskWithHole = [CAShapeLayer layer]; | |
// Both frames are defined in the same coordinate system | |
CGRect biggerRect = CGRectMake(30, 50, 120, 200); | |
CGRect smallerRect = CGRectMake(80, 100, 50, 80); | |
UIBezierPath *maskPath = [UIBezierPath bezierPath]; | |
[maskPath moveToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMaxY(biggerRect))]; | |
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMaxY(biggerRect))]; |
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
- (NSString *)formattedFileSize:(unsignedlonglong)size | |
{ | |
NSString *formattedStr = nil; | |
if (size == 0) | |
formattedStr = @"Empty"; | |
else | |
if (size > 0 && size < 1024) | |
formattedStr = [NSStringstringWithFormat:@"%qu bytes", size]; | |
// Lilac-Annotation: %qu: Unsigned 64-bit integer (unsigned long long) | |
else |
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
//创建一个基于位图的图形上下文并指定大小为CGSizeMake(200,400) | |
UIGraphicsBeginImageContext(CGSizeMake(200,400)); | |
//renderInContext 呈现接受者及其子范围到指定的上下文 | |
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
//返回一个基于当前图形上下文的图片 |
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 *yourImage= [self imageWithImageSimple:image scaledToSize:CGSizeMake(210.0, 210.0)]; | |
- (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize | |
// Create a graphics image context | |
UIGraphicsBeginImageContext(newSize); | |
// Tell the old image to draw in this newcontext, with the desired | |
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
-(BOOL)isValidateEmail:(NSString *)email | |
{ | |
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailRegex]; | |
return [emailTest evaluateWithObject:email]; | |
} |
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
- (BOOL)isModal { | |
if([self presentingViewController]) | |
return YES; | |
if([[self presentingViewController] presentedViewController] == self) | |
return YES; | |
if([[[self navigationController] presentingViewController] presentedViewController] == [self navigationController]) | |
return YES; | |
if([[[self tabBarController] presentingViewController] isKindOfClass:[UITabBarController class]]) | |
return YES; |
OlderNewer