Skip to content

Instantly share code, notes, and snippets.

@hachinobu
hachinobu / サンプル
Created February 14, 2014 04:46
CGGeometryクラスの位置やサイズ操作系の関数紹介 ref: http://qiita.com/hachinobu/items/f8ac32870739c7d4eab8
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(40, 50, 180, 180)];
view1.backgroundColor = [UIColor redColor];
[self.view addSubview:view1];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(70, 90, 180, 200)];
view2.backgroundColor = [UIColor yellowColor];
[self.view addSubview:view2];
CGRect unionRect = CGRectUnion(view1.frame, view2.frame);
NSLog(@"unionRect:%@", NSStringFromCGRect(unionRect));
UIView *unionView = [[UIView alloc] initWithFrame:unionRect];
unionView.backgroundColor = [UIColor clearColor];
@hachinobu
hachinobu / gist:8454619
Created January 16, 2014 13:00
定数の定義方法
//ローカルな定数
static NSString * const kFirstName = @"hachinobu";
//グローバルな定数
//ヘッダーファイル内で宣言
extern NSString * const FirstName;
//実装ファイルで定義
NSString *const FirstName = @"hachinobu";
@hachinobu
hachinobu / gist:8453941
Created January 16, 2014 12:12
NSNumberの便利な使い方
NSNumber *intNum = @1;
NSNumber *floatNum = @1.23f;
NSNumber *doubleNum = @1.2345;
NSNumber *boolNum = @YES;
NSNumber *charNum = @'a';
int numInt = [intNum intValue];
float numFloat = [floatNum floatValue];
double numDouble = [doubleNum doubleValue];
BOOL numBool = [boolNum boolValue];