Objective-C 自定义 UITabBarItem @2x

发布于 2024-09-28 14:28:58 字数 398 浏览 0 评论 0原文

是否可以分配高分辨率的自定义 uitabbaritem 图像?

    UIImage *img;
    img = [UIImage imageNamed:@"[email protected]"];
    self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"more" image:img tag:5];

这不起作用。对于这个用例,是否有解决方法,或者更好的官方链接/解决方案?

谢谢 亚历克斯

is it possible to assign a highres custom uitabbaritem image?

    UIImage *img;
    img = [UIImage imageNamed:@"[email protected]"];
    self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"more" image:img tag:5];

this doesnt work. is there a workaround, or even better an officel link / solution for this usecase?

thanks
alex

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愛上了 2024-10-05 14:28:59

如果您使用 imageNamed,则可以排除 @2x。 imageNamed 的工作方式是,如果您使用的是高分辨率设备,它会自动加载 @2x 文件(如果存在),否则会加载常规文件。

If you're using imageNamed, you can exclude the @2x. The way imageNamed works is that if you're on a high res device it automatically loads the @2x file if it exists, otherwise it loads the regular file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文