2

次のコードを使用する場合:

self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"texture1.png"]];

ビューのテクスチャ バックグラウンドが適切に設定されます。しかし、画像が Retina ディスプレイ用に適切にスケーリングされていないことがわかります。テクスチャと色が本来あるべきリッチではなく、よりピクセル化されているように見えます。他の画像でもこの問題が発生しました。iPhone 5 の画面サイズの画像をフェードアウトさせようとすると、解像度が良好であっても、その一部だけが表示され、残りは切り取られてしまいます。ここで何が欠けているのか分かりますか?

編集:使用している画像のデフォルトの dpi と関係がありますか?

編集#2:スクリーンショットは次のとおりです。 ここに画像の説明を入力

余談ですが、 http://subtlepatterns.com/以外の優れたバックグラウンド テクスチャ ソースを知っている人はいますか?

編集 #3: ios-linen パターンを使用しようとしている私の良い例を次に示します。 ここに画像の説明を入力

4

2 に答える 2

3

@2x 画像を使用している場合は、最初に画像名から .png を削除します

self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"texture1"]];

保持表示の画像の高さと幅を確認してください..

アップルによって On devices with high-resolution screens, the imageNamed:, imageWithContentsOfFile:, and initWithContentsOfFile: methods automatically looks for a version of the requested image with the @2x modifier in its name. If it finds one, it loads that image instead. If you do not provide a high-resolution version of a given image, the image object still loads a standard-resolution image (if one exists) and scales it during drawing.

于 2013-05-24T04:42:31.783 に答える
0

を使用する代わりに、に aをinitWithPatternImage追加する必要があります。これは次の理由でより優れています:-UIImageViewUIView

  1. にはUIImageView、特定の幅と高さに従って画像が含まれます。

  2. また、このメソッドはより多くのメモリinitWithPatternImageを消費します。UIImageView

よりもaを使用したいUIImageView

initWithPatternImage:[UIImage imageNamed:@"texture1.png"]

画像がまだ鮮明でない場合は、@2x 画像を に追加するUIImageViewと、より鮮明になることがわかります。

于 2013-05-24T04:43:28.483 に答える