objective-c - ressizedImageWithCapInsets 或可拉伸(stretch)ImageWithLeftCapWidth :24 topCapHeight:15

标签 objective-c xcode uiimage deprecated

我知道可拉伸(stretch)...是旧的(并且已弃用)..并且可调整大小..是新的 - 但这里有一个大问题...

新方法无法正常工作 - 在我对表格 View 的测试中,我有很多滞后。

我不知道问题出在哪里,但知道“away”行(我知道两者相同):

home = [[UIImage imageNamed:@"homebubble"] resizableImageWithCapInsets:UIEdgeInsetsMake(24.0f, 15.0f, 24.0f, 15.0f)];
away = [[UIImage imageNamed:@"awaybubble"] resizableImageWithCapInsets:UIEdgeInsetsMake(24.0f, 15.0f, 24.0f, 15.0f)];

会出现问题 - 相信我,你不需要我的漏洞代码,我测试了每一行,如果我用离开注释该行,一切都会正常,但如果同时调用两者,它就会滞后。

与旧的相比,它的功能非常完美:

home = [[UIImage imageNamed:@"homebubble"] stretchableImageWithLeftCapWidth:24 topCapHeight:15];
away = [[UIImage imageNamed:@"awaybubble"] stretchableImageWithLeftCapWidth:24 topCapHeight:15];

怎么可能呢?有人对他们有经验吗?谢谢。

最佳答案

现在我知道原因了。

“可调整大小的区域”必须仅为 1px,这一点非常重要。在我的项目中,我有一个 43x32 px 的气泡 - resizabel 区域是 -5x2px (-5 因为 uiedgeinsets 是 24,15,24,15) - 所以它对我来说总是无符号的,aaaand,它必须是 1px。经过更多测试,这是解决方案。

感谢您的回答。

关于objective-c - ressizedImageWithCapInsets 或可拉伸(stretch)ImageWithLeftCapWidth :24 topCapHeight:15,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12055940/

相关文章:

objective-c - Objective C 初学者 : where to put code that needs to be executed once in UITableViewController

objective-c - Objective C 中的舍入时间

iphone - 直接切换到游戏中心应用程序

ios - Xcode 7 错误 : linker command failed with exit code 1 (use -v to see invocation)

ios - xcode ERROR ITMS-90093= 这个包无效。包含 arm64 架构的应用程序不能有最低操作系统版本

ios - 使用 UIImageView 设置缩放 UIScrollView

ios - 如何引用 Images.xcassets 文件夹中的图像

objective-c - 从详细 View 返回后, TableView 不再是 searchResultsTableView

objective-c - 从 MainMenu 获取特定菜单项

iphone - 释放 UIColor PatternImage 的正确方法