0

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

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

我有几个纯色像素,我想将它拉伸到我的整个宽度和高度tabBarItem

你会怎么做?

4

1 回答 1

2

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

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.

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

于 2013-11-08T02:03:51.593 回答