ModalなViewController
表示したいViewの下に半透明なレイヤーを表示して操作させないようにできるViewです。
【2013/05/13 追記】
カテゴリ化し、簡単に導入できるようにしました。
#import <UIKit/UIKit.h> @interface UIViewController (Modal) @property (nonatomic, strong) UIView *_overlayView; -(void)modal; -(void)dismiss; @end @end
#import "ModaViewController.h" #import "AppDelegate.h" #import <objc/runtime.h> @implementation UIViewController (Modal) @dynamic _overlayView; -(NSString*)_overlayView { return objc_getAssociatedObject(self, @selector(set_overlayView:)); } -(void)set_overlayView:(UIView*)view { objc_setAssociatedObject(self, _cmd, view, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -(void)modal; { AppDelegate* app =[[UIApplication sharedApplication]delegate]; UIView *rootView; if(app.window.rootViewController.presentedViewController){ rootView = app.window.rootViewController.presentedViewController.view; } else{ rootView = app.window.rootViewController.view; } [self.view setAlpha:0.0f]; self.view.center = CGPointMake(rootView.bounds.size.width * 0.5, rootView.bounds.size.height * 0.5); self.overlayView.frame = rootView.bounds; [self.overlayView addSubview:self.view]; [rootView addSubview:self.overlayView]; [rootView bringSubviewToFront:self.overlayView]; [UIView animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{ [self.view setAlpha:1.0f]; self.overlayView.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.4f]; } completion:nil]; } -(void)dismiss; { [UIView animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{ self.overlayView.alpha = 0.0f; } completion:^(BOOL finished) { [self.overlayView removeFromSuperview]; self._overlayView = nil; [self removeFromParentViewController]; }]; } - (UIView *)overlayView { if(!self._overlayView) { self._overlayView = [[UIView alloc] init]; self._overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self._overlayView.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.0f]; } return self._overlayView; } @end
年収1000万以上稼ぐ人
なんか響いたので転載
父親は大手の銀行の社長を務めて、30万ドル(約3000万円)以上を稼いでいた。父が自分に教えてくれた大事なことは2つ。
1. 必ず2年前の稼ぎより今は稼いでいなくちゃいけない。会社内で前に進んでいなければ、移る時期だ。
2. 必ず稼いだ10%を投資口座に入れろ。
http://labaq.com/lite/archives/51786273.html
なるほどなぁ
KIF
KIFを入れる手順
cocoaPod編
PodfileにKIFを追加
$ pod setup
$ pod install
workspaceを起動
標準のtargetからPreProcessor Macroの
DEBUG=1
RUN_KIF_TEST=1
を削除
標準のtargetをduplicateする
※duplicate only
target name、product name、schema nameを変える
KIF用のファイルを3つ追加
EXTestController
KIFTestScenario+EXAdditions
KIFTestStep+EXAdditions
AppDelegateにコードを追加
#if RUN_KIF_TESTS #import "EXTestController.h" #endif
application:didFinishLaunchingWithOptions:に追加
#if RUN_KIF_TESTS [[EXTestController sharedInstance] startTestingWithCompletionBlock:^{ // Exit after the tests complete so that CI knows we're done exit([[EXTestController sharedInstance] failureCount]); }]; #endif
UILabelに取り消し線を付けてみた
UILabelに取り消し線を付けたかったので、UILabel拡張してみました。
本当はカテゴリ実装のが使いやすいんだけど…。
lineThrougtフラグを立てると取り消し線が付きます。
こんな感じ
ソースはこちら
LineThrougtLabel.h
@interface LineThrougtLabel : UILabel @property (nonatomic) BOOL lineThrougt; @end
LineThrougtLabel.m
@implementation LineThrougtLabel : UILabel -(void)drawRect:(CGRect)rect { [super drawRect:rect]; if(self.lineThrougt){ [self drawLineThrougt:UIGraphicsGetCurrentContext() rect:rect]; } } -(void)drawLineThrougt:(CGContextRef)context rect:(CGRect)rect { UIColor *color = [self textColor]; CGContextSetStrokeColorWithColor(context, [color CGColor]); CGContextSetLineWidth(context, 2.0f); CGSize size = [self.text sizeWithFont:self.font constrainedToSize:rect.size lineBreakMode:self.lineBreakMode]; CGFloat start = 0; switch (self.textAlignment) { case NSTextAlignmentLeft: start = 0; break; case NSTextAlignmentCenter: start = (self.bounds.size.width - size.width) * 0.5; break; case NSTextAlignmentRight: start = (self.bounds.size.width - size.width); break; case NSTextAlignmentJustified: break; case NSTextAlignmentNatural: break; default: break; } CGContextMoveToPoint(context, start, size.height * 0.5); CGContextAddLineToPoint(context, start + size.width, size.height * 0.5); CGContextStrokePath(context); } @end
はじめてのiOSアプリ -雀録-
リリースしてみました。
麻雀成績管理アプリ -雀録-
https://itunes.apple.com/jp/app/que-lu/id563480838?mt=8
ちょっとバグがでてますが、いま修正版が審査中なのでおまちを…。
作ったきっかけは、自分の麻雀の成績を管理したいなぁ、と思ったからです。
フリーで打っていて、着順をEverNoteとかで付けていたのですが、だんだんとめんどくさくなったわけですね。
ゲームの合間に直ぐ記録できてー、
その日の着順とプラマイがわかってー、
トータルでの平均着順がわかるようなのが欲しいなーと。
個人記録の管理用なので、フリーとかでばんばん打つ人向けです。
1日に4人で打った成績を集計する麻雀のシートとは別モノですね。
そっちのアプリもちょっと作ろうかなーと思っていますが。
というわけで、よろしくお願いしますw
Storyboard使用時のカスタムcellについて
Storyboard使用時はcellが自動的に生成されるっぽい。
だからよくある
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil){ // cellの生成 }
みたいなcellの生成処理はやらなくていい。
あと、自分でカスタムなcellを生成したいときも、init的な処理はStorybordがやってしまうため、addSubviewとかやると再描画時とかにレイアウトが変なことになります。
パーツを動的にレイアウトさせたい場合は、適当にStoryboard上で配置して、Tagを付けて取得しましょう。
-(void)layoutSubviews { UILabel *label = (UILabel *)[cell viewWithTag:1]; // いろいろ処理する }
なんかもっといい方法ある気がするけど、このへんで
脳味噌の休憩は大事
どこかでがむしゃらに仕事をする時期って必要なんだろうけどね
でもやっぱ、適度に休憩いれてかないとダメになっちゃうよ
頭フル回転して酷使してるとね、まとまる考えもまとまらないんですよ
あとクリエイティブな発想もでない
むりやり絞りだそうとしてもロクなことでない
時間があると自然と余裕がでてきて、色々振り返ったり、推敲したりもできる
そうすると次につながるんですよね、改善できるから
それができないと同じこと繰り返すだけになっちゃう
そーゆー仕事してる人多いんだろうなぁ
環境が大事ですよやっぱ、自然とそうさせる環境作りがね