【发布时间】:2013-03-30 18:39:42
【问题描述】:
我已经创建了一个如下的 singup 按钮:
signupButton = [[UIButton alloc] initWithFrame:CGRectMake(10,(facebookLoginButton.bounds.size.height + 40),300,50)];
signupButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
UIImage *signupButtonImage = [[UIImage imageNamed:@"Signup"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
[signupButton setBackgroundImage:signupButtonImage forState:UIControlStateNormal];
上述按钮的框架为 300x50。我创建了一个 22(w)x100(h)px 的图像(用于 Retina 设备)。
图像为 22 像素,其中包括 10px 圆角和 2px 用于可重复的中间部分。
我尝试按照上述代码实现拉伸,插入为 0,10,0,10,但这并没有按预期拉伸。
有人能解释一下插图应该是什么吗?另外如何解决这些问题,我找不到任何有关如何实际计算插图应该是什么的有用信息?我已阅读有关此内容的 Apple 文档,但我不明白如何解决这些问题。
【问题讨论】:
-
将 cap insets 设置为非视网膜图像,在本例中为 0,5,0,5。
标签: iphone ios objective-c ios5 uiimage