This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 336
3.2 UIView のカスタマイズ
tamotamago edited this page Apr 21, 2013
·
9 revisions
UIKit で提供されている view component を組み合わせてカスタムビューを作成すれば、あらゆる場面で再利用可能になり開発効率があがります。
ここではカスタムビューコンポーネントの作成方法として xib を使用した方法と使用しない方法の二つを紹介します。
https://raw.github.com/mixi-inc/iOSTraining/master/Doc/Images/3.2/createUIViewSubClass.png
#import <UIKit/UIKit.h>
@interface MixiCustomizedView : UIView
@end
#import "MixiCustomizedView.h"
@implementation MixiCustomizedView
static CGRect const kSubViewFrame = {{10, 10}, {300, 180}};
static CGRect const kButtonFrame = {{10, 10}, {220, 30}};
// コードで初期化する場合
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self initializeView];
}
return self;
}
// xib を使用する場合
-(id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self){
[self initializeView];
}
return self;
}
-(void)initializeView
{
UIView *subView = [[UIView alloc] initWithFrame:kSubViewFrame];
[subView setBackgroundColor:[UIColor redColor]];
[self addSubview:subView];
UILabel *label = [[UILabel alloc] initWithFrame:kButtonFrame];
label.text = @"hogehoge";
label.backgroundColor = [UIColor clearColor];
[subView addSubview:label];
}
@end
「イメージ」
はじめに
-
導入
-
1.3 UIViewController1 UIViewController のカスタマイズ(xib, autoresizing)
-
UIKit 1 - container, rotate-
-
UIKit 2- UIView -
-
UIKit 3 - table view -
-
UIKit 4 - image and text -
-
ネットワーク処理
-
ローカルキャッシュと通知
-
Blocks, GCD
-
設計とデザインパターン
-
開発ツール
-
テスト
-
In-App Purchase
-
付録