2012-09-05 46 views
1

我想爲UISegmentedControl使用自定義背景圖像,例如「查找我的朋友」。這裏是他們的可調整大小的圖像看起來怎麼樣:如何在代碼中繪製可調整大小的UIImage?

source http://feedzr.com/source.png source http://feedzr.com/inwork.png

如何創建核芯顯卡複雜的陰影效果?

編輯

底部的圖像是多麼上述外觀採用了皮革背景的效果真正UISegmentedControl.There're很多的可調整大小的圖像一樣工作時,如: 底部光澤,頂端內陰影和部分漸變從上到下。

我只是看不到&這個圖像中使用了什麼效果。我不問如何使用UIEdgeInsets。

+0

您的意思是部分超越'Everywhere'細分市場的閃耀效應? –

+0

不,我想畫的是上面的圖片。底部圖像正是上面使用皮革背景時的樣子。像底部光澤,頂部內部陰影和從上到下部分漸變,我只是不能看到如何以及在這個圖像中使用什麼效果。 –

+0

沒有任何「效果」,這些圖像很可能是由設計師在Photoshop中製作的。 –

回答

2

這些只是2張圖片。一個與陰影一個沒有...

你必須創建這些圖像與CapInsets,使他們可以調整大小

例如

UIImage *buttonImage = [[UIImage imageNamed:@"yourImage"] 
    resizableImageWithCapInsets:UIEdgeInsetsMake(1, 11, 0, 20)]; 

要知道UIEdgeInsets的工作原理如下: How does UIEdgeInsetsMake work?

或者在Apple Doc中:

UIEdgeInsetsMake 
Creates an edge inset for a button or view. 

UIEdgeInsets UIEdgeInsetsMake (
    CGFloat top, 
    CGFloat left, 
    CGFloat bottom, 
    CGFloat right 
); 
Parameters 
top 
The inset at the top of an object. 
left 
The inset on the left of an object 
bottom 
The inset on the bottom of an object. 
right 
The inset on the right of an object. 
Return Value 
An inset for a button or view 

Discussion 
An inset is a margin around the drawing rectangle where each side (left, right, top, and bottom) can have a different value. 

Availability 
Available in iOS 2.0 and later. 
See Also 

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html

+0

對不起,我沒有清楚描述我的問題。我編輯它。請看看編輯部分,謝謝@lukaswelte –

相關問題