こんにちは、サービス開発部の氏です。 主にiOSのクックパッドアプリの開発を担当しています。 UICollectionViewLayout みなさん使ってますか? UICollectionView でレイアウトを組む際、実際触り始めると実装するための選択肢が複数あり、どれが最適なのか悩ましい場面に遭遇する人もいるのではないかと思います。 今回は、自分が業務で触れた際に得た知見について軽くお話したいと思います。 UICollectionVIewLayout とは UICollectionView は Cellのサイズや余白等のレイアウトを管理するため、プロパティとして、 UICollectionViewLayout を所持しています。 この UICollectionViewLayout に手をいれることによって、レイアウトを好きな形に変更することができます。 レイアウトを組み立てるときの複数
import UIKit protocol PinterestLayoutDelegate { func collectionView(_ collectionView:UICollectionView, heightForPhotoAtIndexPath indexPath:IndexPath , withWidth:CGFloat) -> CGFloat func collectionView(_ collectionView: UICollectionView, heightForCaptionAndCommentAtIndexPath indexPath: IndexPath, withWidth width: CGFloat) -> CGFloat } class PinterestLayoutAttributes: UICollectionViewLayoutAttribute
※2017.07.31追記: 「MOREMALL(モアモール)」事業、サービス終了のお知らせ 初めまして、Objective-C未経験Swift歴6ヶ月のamitanです。 WWDC2015 にてSwift2.0オープンソース化が発表されて、テンションMAXです!! UICollectionViewはiOS 6.0で追加された、 grid形式で表示可能なViewです。 今回は、MOREMALLアプリでも使用されているUICollecionViewFlowLayoutを継承したお手軽カスタマイズ方法をご紹介します。 UICollectionViewでのアニメーション方法についてはこちらからどうぞ。 カスタムレイアウトの作成 列数及び縦横の長さ、行列の位置を指定することで、UICollectionViewに描画ができるカスタムレイアウトを作成します。 ソースコードはgithubにあります。 開
April 1, 2017 404 Not Found ブログのシステムを移行したため、記事の URL が変わっています。 記事自体は全て移しましたので、 トップページ swiswiswift.com の記事リストの中から検索していたければ記事が見つかると思います。 よろしくお願いします。
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work. Try for free Learn more
ジェネリクス 型をパラメーターとして扱う方法。型を抽象化できて便利なコードを書けるようになる。 Swiftの標準ライブラリーの多くがジェネリクスを使っている。 この記事ではジェネリクスを使っていないコードとジェネリクスを使ったコードを比較して、ジェネリクスの有効性から使い方までみていきます。 ジェネリクスを使わないイケてないコード Int型の引数2つを入れ替える関数を作ってみます。 func swapTwoInts(inout a: Int, inout _ b: Int) { let temporaryA = a a = b b = temporaryA } このswapTwoInts(_:_)関数を実行してみます。 var someInt = 3 var anotherInt = 107 swapTwoInts(&someInt, &anotherInt) print("someInt
100 Days of Swift I started learning swift and kept going for 100 days. Each day, I tried to build something from what I learned. Most projects took a few days to complete. Below is my progression from day one to a hundred in the form of completed projects. A total of 40 projects. Read more about this on Medium I learned how to: Build custom transparent navigation bar Implement a Collection View i
I’m a huge fan of UICollectionView. It’s way more customizable than his older brother UITableView. Nowadays I use collection view even more often than table view. With iOS 9 it supports easy reordering. Before it wasn’t possible out of the box, and to do so means painful work. Let’s have look at the API. You can find the accompanying Xcode project on GitHub. The easiest way to add easy reordering
In this two-part tutorial series, you’ll develop a nifty iOS book open animation and page flip animation similar to Paper by FiftyThree: In Part 1 you’ll learn how to customize your collection view layouts and apply depth and shadow to make the app look realistic. In Part 2, you’ll learn to create custom transitions between different controllers in a sensible way and integrate gestures to create n
最近iOSのアプリ開発ばかりしています。 通信や非同期での処理、ユーザアクションなど、様々な箇所でコールバックを受けたい場合があって、それぞれ適した使いどころがあると思ったのでまとめます。 方法は3つ Protocol Closure NSNotification 一つずつ説明していきます。 Protocol 一つは、Protocolを用いたDelegateパターンです。 次のように記述します。 protocol TaskDelegate { func complete(result: AnyObject) func failed(error: NSError) } final class Task { var delegate: TaskDelegate? ... func someTask() { ... someTaskResult(someResult, error: error)
One more post on writing generic algorithms. Let’s take a non-trivial non-generic algorithm and write a generic version. We’ll port a Java implementation of merge sort, and also look at some other interesting things we might do to some Java code when converting it to Swift. Why bother with a merge sort? Well, the standard library comes with a very efficient in-place sort, based on the introsort, b
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く