5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iOS tech videoのArchitecting Modern Apps, Part 1のまとめ

Last updated at Posted at 2014-01-25

ざっくり

このサイトのvideoを参考に作りました。 https://developer.apple.com/tech-talks/videos/
iOS7で新しく追加されたMotionとUIViewControllerとTextkitについて説明。特にcustom transitionについて詳しく説明していた。

Motion

Motion Effects

iOS7ではデバイスの合わせて画像を動かすことで奥行きを作ってよりリアルな体験を提供している。
UIMotionEffectは、abstract classで、簡単にsubclassが作成できる。加速度センサーの情報を受け取っており、UIInterpolatingMotionEffectで使われている。
使い方の例はこちら。

UIInterpolatingMotionEffect *xAxis;

xAxis = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x"           type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];

xAxis.minimumRelativeValue = @-40;
xAxis.maximumRelativeValue = @40;

UIInterpolatingMotionEffect *yAxis;

yAxis = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y"           type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];

yAxis.minimumRelativeValue = @-40;
yAxis.maximumRelativeValue = @40;

UIMotionEffectGroup *group = [[UIMotionEffectGroup alloc] init];
group.motionEffects = @[xAxis, yAxis];

[view addMotionEffect:group];

Dynamics

よりリアルさを追求できる、物理エンジンで、衝突やバネや重力を実装できる。強調させたいときに使えるテク。
ロック画面からカメラを出すときなどに使われている。

Custom Transitions

custom transitionsは、protocolによって定義されたオブジェクトで、sandboxの中で実行される。完了した時にnotificationを送らなければいけない。

Custom Transitionのライフタイム
スクリーンショット 2014-01-26 3.42.39.png

view controllerがどのように変化したかtransitioning delegateに聞く。変化のタイミングをコントロールできるオブジェクトを提供している。
Animated Transitioning Objectは、transition中に定義されていて、変化のアニメーションを実行している。animationが完全に終わったときに知らせをする。
Transition Contextは、system-providedなobjectでtransitionのメタデータを提供していて、animationが完全に終わったことを示すために使われる。

interactive transition

animationの前にinteractionを起こしたいときや、Transition delegateでメソッドを定義したいときは、interactive transitionを利用する。

UIPercentDrivenInteractiveTransitionは、cancelとupdateとfinishをanimated tansitioningに伝えることができる。またUIViewのanimationと一緒に使用することができる。

スクリーンショット 2014-01-26 4.07.06.png

スクリーンショット 2014-01-26 4.08.48.png

Custom Transitionの使用例
http://www.doubleencore.com/2013/09/ios-7-custom-transitions/

UIViewController

topbar

UIViewControllerの大きさは、iOS6ではnavigation barやstatus barの下からだったが、iOS7ではbarの下にUIViewControllerがある。
scrollViewの場合は、contentInset.topがデフォルトで64になる

スクリーンショット 2014-01-26 4.15.28.png

statusbar

status barのカスタマイズもview controllerごとに可能になり、styleやanimationを追加することができる。animationのtimingもカスタムすることができる

@property BOOL shouldBeHidingStatusBar;

- (BOOL)prefersStatusBarHidden {
    return self.shouldBeHidingStatusBar;
}

- (IBAction)hideStatusBar {
    self.shouldBeHidingStatusBar = YES;
    [UIView animateWithDuration:0.5 animations:^{
        [self setNeedsStatusBarAppearanceUpdate];
    }];
}

- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
    return UIStatusBarAnimationSlide;
}

Textkit

文字の大きさをシステムで指定した大きさに動的に変更することができる。
UIContentSizeCategoryDidChangeNotificationというnotificationを受け取ることで、customのフォントでも大きさを変更させることができる。

- (void)dynamicTypeChanged:(NSNotification *)note {
    UIApplication *app = [UIApplication sharedApplication];
    NSString *category = app.preferredContentSizeCategory;

    if ([category isEqual:UIContentSizeCategorySmall]) {
        ...    
    } else if ([category isEqual:UIContentSizeCategoryMedium]) {
        ...
    } else if ([category isEqual:UIContentSizeCategoryLarge]) {
        ...
    }
}

備考

wantedlyでは、iOSアプリのテストと、iOSエンジニアとの交流を目的に募集出してみます。気軽に遊びにきてください!
https://www.wantedly.com/projects/5444

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?