Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /home/users/1/juny/web/hidef/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /home/users/1/juny/web/hidef/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

[Swift] Asset Catalogについて

公開日: : iPhone App 開発, Swift


Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /home/users/1/juny/web/hidef/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524

XCode5から追加されたAsset Catalog。
いままで標準のImages.xcassetsしか使っていませんでした。
AppIconがアプリのアイコン。
LaunchImageが起動イメージ。

アプリ内で使用する画像は別で管理していましたが、Asset Catalogを使えばデバイスごとにひとまとめにできるし、画面単位でフォルダ分けも可能です。

Asset Catalogの作成

試しにViewControllerで使うAsset Catalogを作成してみます。
まず、右クリックでNew File…を選択。
スクリーンショット 2014-12-18 15.50.14

 

Asset Catalogを選択し、
スクリーンショット 2014-12-18 14.58.40

 

名前をViewController.xcassetsにしてCreate。(名前はなんでもいいです)
スクリーンショット 2014-12-18 15.42.41

 

ViewController.xcassetsができたら右クリックし、New Image Setを選択します。
スクリーンショット 2014-12-18 15.43.29

 

画像名をsampleにし、それぞれの倍率に応じた画像をドラッグ&ドロップで追加します。
スクリーンショット 2014-12-18 15.44.47

サンプルコード

画像を使用する場合はこんな感じ。

self.imageView.image = UIImage(named: "sample")

ちなみにAsset Catalog内でフォルダ分けをしても取得の際は画像名だけでOKです。
※同じ画像名が複数あった場合は警告が出ます。

ad

関連記事

[Swift] CoreDataのテーブルからデータ件数を取得する

件数を取得する fetchResultsControllerなどを使わず、直接テーブルのデータ件数

記事を読む

[Swift] Swiftでいろんなfor文まとめてみた

いろんなfor文 プログラム作成で必ず出てくるfor文を自分なりにまとめてみました。 Swift

記事を読む

[Objective-C] 文字列操作の便利Tips

Tipsいろいろ 先日の投稿 共通関数をまとめたクラスを作ろう!の流れで、文字列を操作するときに便

記事を読む

[Swift] optional値の設定(??)

optional値がnilの時 プロジェクトでのテンプレートを選択した時にソースコードが自動生成さ

記事を読む

[iPhone App] WorkManagerの不具合について

バージョン1.2.2の不具合 11/25日現在、iPhoneアプリの「WorkManger」バージ

記事を読む

[Swift] UINavigationControllerで戻るイベントを取得する

UINavigationController UINavigationControllerを使用し

記事を読む

no image

迷走継続中!

どうも、僕です。 相変わらず迷走中な訳ですが、新たに迷走アイテムを入手しました。 その名

記事を読む

Xcode5のstoryboard内でUIKeyCommandエラーの対処法

既存のプロジェクトからstoryboardにあるオブジェクトをコピペして、新規プロジェクトに貼付けた

記事を読む

iPhoneApp WorkManager公開されました!

きっとリジェクトされるんだろうなと思いながら申請を出して1週間。 本日、公開のメールが届きまし

記事を読む

no image

OSSの使い方がわからない・・・。

チュートリアル系の、storyboradでview controllerを置いて画面遷移を設定してっ

記事を読む

ad

Message

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

ad

[PHP] curl転送してみる(googleに)

curlでgoogle画像検索APIにアクセスしてみます。 cu

[PHP] PDOでMySQLの接続確認をする

PDO PHPでMySQLに接続する際には、mysql_connec

[PHP] ランダムな英数字を生成する

便利系メソッド 今回はPHPでランダムな英数字を作成してみます。

[Swift] プロパティリスト(plist)の値を取得

plistからデータを取得してみます。 こちらのエントリーも参考にし

[Swift] Asset Catalogについて

XCode5から追加されたAsset Catalog。 いままで標準

→もっと見る

  • 1978年の七夕生まれ。 25才でweb業界の門を叩き、28才でフリーランスに。 現在は、フリーランスでマークアップ中心に、wordpressのカスタマイズやデザインをしております。 また、iPhoneアプリの開発もしております。

Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /home/users/1/juny/web/hidef/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524
PAGE TOP ↑

Warning: Use of undefined constant user_level - assumed 'user_level' (this will throw an Error in a future version of PHP) in /home/users/1/juny/web/hidef/wp-content/plugins/ultimate-google-analytics/ultimate_ga.php on line 524