如何在iOS中拉伸iOS UITabBarItem背景 [英] How to stretch iOS UITabBarItem background in iOS

查看:84
本文介绍了如何在iOS中拉伸iOS UITabBarItem背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我现在正在使用的:

This is what I'm using now:

tabBarController.tabBar.selectionIndicatorImage = [UIImage imageNamed:@"image.png"];

我有几个纯色像素a,我想将其拉伸到我 tabBarItem

I have a couple pixels a of a solid color and I would like to stretch it the full width and height of my tabBarItem

您将如何做?

推荐答案

这应该有助于解决您的问题

This should help solve your problem

tabBarController.tabBar.selectionIndicatorImage = [[UIImage imageNamed:@"image.png"]
                  resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];

摘自Apple文档

    During scaling or resizing of the image, areas covered by a cap are not scaled or 
resized. Instead, the pixel area not covered by the cap in each direction is tiled, left-to-
right and top-to-bottom, to resize the image. This technique is often used to create 
variable-width buttons, which retain the same rounded corners but whose center region grows
 or shrinks as needed. For best performance, use a tiled area that is a 1x1 pixel area in size.

由于我们将边缘插图设置为零,因此图像将被拉伸以覆盖整个区域.

Since we are setting the edge insets to be zero the image will be stetched to cover the entire area.

这篇关于如何在iOS中拉伸iOS UITabBarItem背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆