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
// Returns the bold version of a font. May return nil if there is no bold version. | |
UIFont *RNGetBoldFontForFont(UIFont *font) { | |
UIFont *result = nil; | |
CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef)(font.fontName), | |
font.pointSize, NULL); | |
if (ctFont) { | |
// You can't add bold to a bold font | |
// (don't really need this, since the ctBoldFont check would handle it) | |
if ((CTFontGetSymbolicTraits(ctFont) & kCTFontTraitBold) == 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
if (sqlite3_open([DATABASE UTF8String], &database) == SQLITE_OK) | |
{ | |
NSString *sql = [NSString stringWithFormat:@"update lpb set %@ = '%@' where level='%@'", self.typeString, self.iconString, self.levelString]; | |
if (sqlite3_exec(database, [sql UTF8String], NULL, NULL, &error) != SQLITE_OK) | |
NSLog(@"LPBERROR: %@ , %s",sql, error); | |
sqlite3_close(database); | |
} |
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)decompressImage:(UIImage *)image | |
{ | |
UIGraphicsBeginImageContext(CGSizeMake(1, 1)); | |
[image drawAtPoint:CGPointZero]; | |
UIGraphicsEndImageContext(); | |
} | |
This causes the image to decompress |
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设置圆角(小于4个角) UIBezi erPath + UIShapeLayer | |
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)]; // byRoundingCorners : 指定需要圆角的角,UIRectCorner类型 | |
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; | |
maskLayer.frame = view2.bounds; | |
maskLayer.path = maskPath.CGPath; | |
view2.layer.mask = maskLayer; | |
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
从视频文件中获得一张图片(截图) | |
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:nil]; | |
AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset]; | |
gen.appliesPreferredTrackTransform = YES; | |
CMTime time = CMTimeMakeWithSeconds(0.0, 600); | |
NSError *error = nil; | |
CMTime actualTime; | |
CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&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
iOS 获取当前WIFI名字 | |
+ (NSString *)GetCurrentWifiHotSpotName { | |
NSString *wifiName = nil; | |
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces(); | |
for (NSString *ifnam in ifs) { | |
NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam); | |
NSLog(@"info:%@",info); | |
if (info[@"SSID"]) { wifiName = info[@"SSID"]; } | |
} |
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
//NSLocale中取出国家country信息并按照国家名字排序 | |
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en"]; | |
NSArray *countryCodes = [NSLocale ISOCountryCodes];// 所有国家编码 | |
NSMutableArray *countriesUnsorted = [[NSMutableArray alloc] initWithCapacity:countryCodes.count]; | |
for (NSString *countryCode in countryCodes) { | |
NSString *displayNameString = [locale displayNameForKey:NSLocaleCountryCode value:countryCode];// 获得编码对应的国家名字 |
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) validateEmail: (NSString *) candidate { | |
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:candidate]; | |
} | |
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
// rate | |
[Appirater setAppId:kAppStoreID]; | |
[Appirater setOpenInAppStore:YES]; // 设置为NO,in-app方式打开 | |
[Appirater setDaysUntilPrompt:1]; // 1天过后 | |
[Appirater setUsesUntilPrompt:10]; // 使用10次 | |
[Appirater setSignificantEventsUntilPrompt:-1]; | |
[Appirater setTimeBeforeReminding:2]; | |
[Appirater appLaunched: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
#!/usr/sbin/dtrace -s | |
/* Run like: | |
% sudo csh | |
# ./spy.d $PROCESS_ID [$INTERESTING_PROBEPROV] | |
Prints a line of dashes every 5 seconds to delineate different experiments. | |
*/ | |
#pragma D option quiet |
OlderNewer