我想做一个cell
像邮件应用程序一样滑动操作。
I set UIImage
to backgroundColor
的行动作。
action.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"remove"]];
But i get my image repeated side-by-side on the background. like this.
![](https://i.stack.imgur.com/rq4eR.jpg)
是图片大小的问题吗?
可以告诉我如何修复它,或者其他方法吗?
是的,这是图像尺寸问题。
即使我有类似的要求并面临同样的问题。在这种情况下,当您使用时,
action.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"remove"]];
即使您将 imageView.contentMode 设置为:
UIViewContentModeScaleAspectFit
UIViewContentModeScaleToFill
UIViewContentModeScaleAspectFill
如果您正在使用的图像的大小和单元格上按钮的大小不匹配,则图像将不会拉伸以填充整个按钮,而是图像图案将重复自身,直到按钮的整个区域都被填充。使用。
这是因为您设置的是“backgroundColor”而不是实际的“backgroundImage”。与“backgroundImage”不同,“backgroundColor”不遵循按钮的 UIContentMode。
因此,您需要做的是创建一个与按钮大小完全相同的图像。如果您的单元格具有动态高度(根据您的内容在运行时确定的高度),则无法执行此操作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)