Skip to content

Instantly share code, notes, and snippets.

View CaliosD's full-sized avatar
🎯
Focusing

Calios CaliosD

🎯
Focusing
  • Ubuntu
View GitHub Profile
@CaliosD
CaliosD / xcode-build-bump.sh
Created December 1, 2015 09:10 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# 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)
@CaliosD
CaliosD / DateFlowLayout.h
Created December 8, 2015 08:26 — forked from vigorouscoding/DateFlowLayout.h
UICollectionView with sticky headers which works for horizontal as well as vertical scrolling
#import <UIKit/UIKit.h>
@interface DateFlowLayout : UICollectionViewFlowLayout
@end
@CaliosD
CaliosD / TVCelliOS9Killer.m
Created January 21, 2016 03:52
Unexpected margin in UITableViewCell in iOS9
if([tableview respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)]) {
tableview.cellLayoutMarginsFollowReadableWidth = NO;
}
@CaliosD
CaliosD / 0_reuse_code.js
Created February 3, 2016 08:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
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))];
@CaliosD
CaliosD / fileSizeCal.m
Created March 21, 2016 02:29
求文件大小
- (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
@CaliosD
CaliosD / screenCapture.m
Created March 21, 2016 02:34
截取屏幕图片
//创建一个基于位图的图形上下文并指定大小为CGSizeMake(200,400)
UIGraphicsBeginImageContext(CGSizeMake(200,400));
//renderInContext 呈现接受者及其子范围到指定的上下文
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
//返回一个基于当前图形上下文的图片
@CaliosD
CaliosD / imageCompress.m
Created March 21, 2016 02:36
图片压缩
// 用法: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
@CaliosD
CaliosD / emailValidator.m
Created March 21, 2016 02:37
判断邮箱格式是否正确(利用正则表达式验证)
-(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];
}
- (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;