假设我有这个精灵:
mbm
bcb
mbm
每个字母都代表一部分。(m:边距; b:边框; c:居中)
我想要一个类,能够重复b和c直到填满视图,这样我就可以得到如下效果:
mbbbbbbbbbbbbbm
bcccccccccccccb
bcccccccccccccb
bcccccccccccccb
mbbbbbbbbbbbbbm
已经有类似的东西了吗? 如果没有,有什么实现的想法吗?
假设我有这个精灵:
mbm
bcb
mbm
每个字母都代表一部分。(m:边距; b:边框; c:居中)
我想要一个类,能够重复b和c直到填满视图,这样我就可以得到如下效果:
mbbbbbbbbbbbbbm
bcccccccccccccb
bcccccccccccccb
bcccccccccccccb
mbbbbbbbbbbbbbm
已经有类似的东西了吗? 如果没有,有什么实现的想法吗?
-(UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight
(请参见苹果UIImage类参考)UIImage *image = [UIImage imageNamed:@"img_loginButton.png"];
UIEdgeInsets edgeInsets;
edgeInsets.left = 3.0f; //Assume it is the pixel for starting 'm'
edgeInsets.top = 0.0f;
edgeInsets.right = 3.0f; //Assume it is the pixel for Ending 'm'
edgeInsets.bottom = 0.0f;
image = [image resizableImageWithCapInsets:edgeInsets];
//Use this image as your controls image