Skip to content

Instantly share code, notes, and snippets.

View tuchangwei's full-sized avatar

Changwei tuchangwei

View GitHub Profile
@tuchangwei
tuchangwei / curl
Created April 11, 2014 08:46
Some demo to show how to use curl command.
curl -X GET "http://192.168.1.200:808/workFlowWebService.asmx/GetAndriodInitDBListAL"
curl --dump-header - -H "Content-Type: application/x-www-form-urlencoded" -H "Content-Length: 0" -X POST "http://192.168.1.200:808/workFlowWebService.asmx/GetAndriodInitDBListAL"
@tuchangwei
tuchangwei / GDC
Created May 5, 2015 10:06
GDC Demo
var group = dispatch_group_create()
var queue = dispatch_queue_create("me.tutuge.test.gcd", DISPATCH_QUEUE_CONCURRENT);
dispatch_group_async(group, queue, { () -> Void in
NSThread.sleepForTimeInterval(10)
println("First block done...")
})
dispatch_group_async(group, queue, { () -> Void in
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
#else
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTy
+ (NSString *) appVersion
{
return [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
}
+ (NSString *) build
{
return [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *)kCFBundleVersionKey];
}
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//RGB color macro
#define NormalBlue 0x25aae1
#define PressedBlue 0x1A7AA2
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
//RGB color macro with alpha
- (void)customAppearance {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
//[[UINavigationBar appearance]setBackgroundColor:[UIColor colorWithRed:26.0/255 green:26.0/255 blue:129.0/255 alpha:1.0]];
[[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:@"navbar_bg"]forBarMetrics:UIBarMetricsDefault];
if([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {
[[UINavigationBar appearance]setTranslucent:NO];
显示文档: Ctr+J
查找调用位置:Ctrl + Option + H
<!--抽屉效果, 有两部分组成,上边部分是主view, 下边部分是抽屉部分,抽屉部分的抽出方向由android:layout_gravity="start"这个参数决定-->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
//app为自定义namespace的名称
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 主view由相对布局构成-->
<RelativeLayout