Akira Iwaya / @hoshi_gaki
iOS 7 なMessage Appの作り方
@hoshi_gaki岩谷 明いわや あきら
アルバイトなプログラマ(千葉大学工学部デザイン学科4年生)
FRED PERRY会員証アプリ
フジロック用アプリ(非公式) お手伝いしました
Summaly
資生堂 店頭用商品紹介アプリ
iOS 7 のメッセージアプリ
下にスワイプするとキーボードが隠れる
吹き出しにグラデーションがついてる
もにょもにょ動く
(apple.com より)
2
3
1
もにょもにょ動く1
・UICollectionView + UIDynamicsで実現できる - WWDC 2013 Session 217 “Exploring Scroll Views on iOS 7” - objc.io issue #5 “UICollectionView + UIKit Dynamics” www.objc.io/issue-5/collection-views-and-uidynamics.html
・UICollectionViewFlowLayout のサブクラスを作る - UIDynamicAnimatorと UIAttachmentBehaviorの組み合わせ - それ用メソッド [self.dynamicAnimator layoutAttributesForCellAtIndexPath:]
- [self.collectionView.panGestureRecognizer locationInView: self.collectionView] でタッチをとれる
吹き出しにグラデーションがついてる2※自分で思いついた方法です
1. UICollectionViewLayoutAttributesのサブクラスを作る
←グラデーション用に色を保持する配列
2. UICollectionViewCellのサブクラスを作る ・-(void)applyLayoutAttributes:に作ったサブクラスが渡ってくるので,CAGradientLayerに設定する
・背景色をグラデーションにするためにグラデーション用View の +(Class)layerClassで [CAGradientLayer class]を返す self.layer.cornerRadius = 15.0f; self.layer.maskToBounds = YESで角を丸くする
3. UICollectionViewFlowLayoutのサブクラスで色をセットする・+(Class)layoutAttribuetClassでカスタマイズした UICollectionViewLayoutAttributesの クラスを返す・layoutAttributesForElementsInRect:と layoutAttributesForIteAtIndexPath:で色を計算するメソッドをよびだして,カスタマイズした UICollectionViewLayoutAttributesのサブクラスに色を設定- (void)assignGradientColorsToLayoutAttributes:(NSArray *)layoutAttributes - (NSArray *)colorsForBeginPosition: endPosition withColors:(NSArray *)colors colorsIdeintifier:(NSString *)colorsIdentifier loations:(NSArray *)locations
などなど… 詳しくはGitHubで!
下にスワイプするとキーボードが隠れる3
・iOS 7 からうってつけのAPI が追加 scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; これでスワイプ時に勝手に隠してくれる。
But
Message アプリやLINEなどのように自動でUITextViewを追従させたりはしてくれない。
・そこで
・fork 元のものにAutolayout + iOS 7 対応したもの
ziryanov / DAKeyboardControlforked from danielamitay / DAKeyboardControl
https://github.com/ziryanov/DAKeyboardControl
以上をまとめたプロジェクトを作りました !
AIiOS7MessageSample
・某アプリを iOS7リデザインした風UI・AutoLayout による可変幅セル・UIDynamics・グラデーション吹き出し・スワイプで閉じるキーボード
https://github.com/akira108/AIiOS7MessageSample
以上をまとめたプロジェクトを作りました !
AIiOS7MessageSample
・某アプリを iOS7リデザインした風UI・AutoLayout による可変幅セル・UIDynamics・グラデーション吹き出し・スワイプで閉じるキーボード
https://github.com/akira108/AIiOS7MessageSample
ご静聴ありがとうございました。