2012-09-05 50 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 –

相关问题