Skip to content

Instantly share code, notes, and snippets.

View WenchaoD's full-sized avatar
🤒
I may be slow to respond.

Wenchao Ding WenchaoD

🤒
I may be slow to respond.
View GitHub Profile
@WenchaoD
WenchaoD / GetDaysBetweenTwoDays.m
Created September 18, 2016 03:38
Get dates between two days
NSDate *fromDate = ...;
NSDate *toDate = ...;
NSCalendar *gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
NSInteger daysDiff = [gregorian components:NSCalendarUnitDay fromDate:fromDate toDate:toDate options:0].day;
NSMutableArray<NSDate *> *array = [NSMutableArray arrayWithObject:fromDate];
for (int i = 1; i <= daysDiff; i++) {
NSDate *date = [gregorian dateByAddingUnit:NSCalendarUnitDay value:daysDiff toDate:toDate options:0];
if (date) [array addObject:date];
}
NSArray<NSDate *> *dates = array.copy;
@WenchaoD
WenchaoD / GetLaunchImage.m
Last active September 23, 2015 05:49
iOS get lauchImage
NSDictionary *launchImageNames = @{
@"320x480" : @"LaunchImage-700@2x.png",
@"320x568" : @"LaunchImage-700-568h@2x.png",
@"375x667" : @"LaunchImage-800-667h@2x.png",
@"414x736" : @"LaunchImage-800-Portrait-736h@3x.png"
};
NSString *aspect = [NSString stringWithFormat:@"%@x%@",@([UIScreen mainScreen].bounds.size.width),@([UIScreen mainScreen].bounds.size.height)];
UIImage *launchImage = [UIImage imageNamed:launchImageNames[aspect]];
@WenchaoD
WenchaoD / Code-snip.m
Last active August 29, 2015 14:26
iOS - Change default locale
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"de", @"en", @"fr", nil] forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize]; //to make the change immediate
@WenchaoD
WenchaoD / Readme - TagFlowLayout.md
Last active May 12, 2020 03:40
Subclass UICollectionViewFlowLayout to build a tag layout, and make UICollectionView scrolling smonthly while it holds dozens of cells with round corner
We couldn’t find that file to show.