很难理解resizableImageWithCapInsets

时间:2013-03-22 15:43:45

标签: ios uibutton

我有一个UIButton,我正在尝试将可调整大小的图像设置为背景。图像大小为25X25。我使用以下代码来设置图像。

UIImage *backgroundImage = [[UIImage imageNamed:@"barbutton_normal"] resizableImageWithCapInsets:UIEdgeInsetsMake(3, 2, 3, 2)];

    [self setBackgroundImage:backgroundImage forState:UIControlStateNormal];

    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

    [self setTitleEdgeInsets:UIEdgeInsetsMake(10,10, 10, 10)];

    self.layer.cornerRadius = 6.0;
    self.layer.masksToBounds = YES;

但按钮显示如下:

enter image description here

我做错了什么?另外,如何使按钮的顶部和底部变得更大,以免它看起来像文字一样。

0 个答案:

没有答案