// TODO: ToDoリストを記述する
// FIXME: 修正項目などを記述する
// !!!: 重要項目を記述する
// ???: 不明点を記述する
#pragma mark
//メソッドの区切りに使う
#warning 警告メッセージ
#error エラーメッセージ
2015年12月14日月曜日
2015年12月7日月曜日
継承したクラスのdelegateメソッドを表示
2015年11月28日土曜日
2014年10月13日月曜日
UINavigationBarのtitle、backButtonのフォントを変える
まず、「AppDelegate.m」の『- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions』に、
次に、NavigationControllerの『ViewDidLoad』に、
それはそうと、m+フォントってとても美しいよね
UIFont *barButtonTitleFont = [UIFont fontWithName:@"mplus-2p-light" size:13];
UIColor *barButtonTitleColor = [UIColor whiteColor];
[[UIBarButtonItem appearance] setTitleTextAttributes:@{UITextAttributeFont:barButtonTitleFont, UITextAttributeTextColor:barButtonTitleColor} forState:UIControlStateNormal];
を記述。これで、BackButtonのフォントが変わる次に、NavigationControllerの『ViewDidLoad』に、
UILabel* label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 44)];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:@"mplus-2p-light" size:22.0f];
label.textColor = [UIColor flatWhiteColor];
label.text = @"タイトル";
label.textAlignment = NSTextAlignmentCenter;
self.navigationItem.titleView = label;
を記述。これで、タイトルのフォントが変わる。それはそうと、m+フォントってとても美しいよね
ラベル:
iOS,
objective-C,
アプリ
アプリ起動時に指定した画像を表示させる
アプリを起動した時に指定した画像を表示させる
(Twitterの公式クライアントアプリとかであるやつ)
(Twitterの公式クライアントアプリとかであるやつ)
- プロジェクト中にある「images.xcassets」を開いて、起動時に表示したい画像をドラッグアンドドロップで設定する。

ちなみに、必要な画像サイズはinspectorに書いてある。
- 「info.plist」に「Status bar is initially hidden」 という項目を追加して、Boolean型のYESに設定する。
- 同じく、「View controller-based status bar appearance」という項目を追加して、Boolean型のNOに設定する。
これで、起動時からステータスバーが表示されなくなる。 - 「AppDelegate.m」の-『 (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions』に、
[NSThread sleepForTimeInterval:1.0]; [UIApplication sharedApplication].statusBarHidden = NO;
を記述する。
これで、起動から1秒間、設定した画像が表示される
あとは、フェードアウトするアニメーションを追加したい・・・
2014年10月11日土曜日
インスタンスメソッドの定義方法
今更ながらObj-Cの文法まとめ
あってるかなあ?
・きっちりしたインスタンス変数の定義
sampleClass.h
例えば、_stringをセットしたついでに、UILabel.textに_stringをセットしたり
・self.propertyの使いどころ
getter/setter/init/deallocのみ_propertyを使い、
その他はself.propertyを使う
あってるかなあ?
・きっちりしたインスタンス変数の定義
sampleClass.h
@interface sampleClass:NSObject
{
NSString *_string; //インスタンス変数の定義
double _number; //インスタンス変数の定義
}
@property (nonatomic) NSString* string; //プロパティを記述すると、getterとsetterが自動で生成される
@end
sampleClass.m
@implementation sampleClass
@synthesize string = _string; //インスタンス変数とプロパティを明示的に紐付ける
//プロパティを記述していない場合、自分でgetterとsetterを作る
- (double)number{
return _number;
}
- (void)setNumber:(double)number{
_number = number;
}
@end
setter/getterを自分で作る場合の利点は、setter/getter内に好きなことを記述できる例えば、_stringをセットしたついでに、UILabel.textに_stringをセットしたり
・self.propertyの使いどころ
getter/setter/init/deallocのみ_propertyを使い、
その他はself.propertyを使う
2014年10月6日月曜日
JASidePanelControllerでサイドパネルを開くたびに呼ばれるメソッド
JASidePanelControllerを使ってみて、サイドパネルを開くたびにビューを更新しようと思ったけど、デフォルトでその機能がないみたいなのでメモ
JASidePanelController.hに
JASidePanelController.mで
これで、右のサイドパネルを開くたびに
show right panel
とログが表示される
JASidePanelController.hに
- (void)prepareShowRightPanel;を追記
JASidePanelController.mで
- (void)_showRightPanel:(BOOL)animated bounce:(BOOL)shouldBounce {
self.state = JASidePanelRightVisible;
[self _loadRightPanel];
[self _adjustCenterFrame];
if (animated) {
[self _animateCenterPanel:shouldBounce completion:nil];
} else {
self.centerPanelContainer.frame = _centerPanelRestingFrame;
[self styleContainer:self.centerPanelContainer animate:NO duration:0.0f];
if (self.style == JASidePanelMultipleActive || self.pushesSidePanels) {
[self _layoutSideContainers:NO duration:0.0f];
}
}
if (self.style == JASidePanelSingleActive) {
self.tapView = [[UIView alloc] init];
}
[self prepareShowRightPanel];//これを追加
[self _toggleScrollsToTopForCenter:NO left:NO right:YES];
}
次に、JASidePanelControllerのサブクラスに
- (void)prepareShowRightPanel {
NSLog(@"show right panel");
}
を記述これで、右のサイドパネルを開くたびに
show right panel
とログが表示される
登録:
投稿 (Atom)





