简体   繁体   English

iPhone - 按钮背景图像

[英]iPhone - Buttons background image

I've added some buttons to my app with a background image (RESET button below), but the corners are quite as expected. 我已经在我的应用程序中添加了一些带有背景图像的按钮(下面的RESET按钮),但角落非常符合预期。 See below: 见下文:

替代文字

The bottom left and right corners of the RESET button seem to be squared. RESET按钮的左下角和右下角似乎是平方的。 My original image has rounded corners. 我的原始图像有圆角。

Anyone come across this problem before ? 以前有人遇到过这个问题吗?

There's nothing tricky about changing the image for a button(I did it lots of times), as long as you follow a couple of simple steps: 只要你按照几个简单的步骤,改变按钮的图像(我做了很多次)并没有什么棘手的问题:

  1. your button image must have a transparent background 您的按钮图像必须具有透明背景
  2. your button must be set as Custom (and NOT Round Rect) 你的按钮必须设置为Custom(而不是Round Rect)
  3. your button's background color must have Opacity=0 按钮的背景颜色必须为Opacity = 0

In order to change the button background color, when you change the color make sure you click on the left side of the color combobox, so that you get presented the color picker. 为了更改按钮背景颜色,当您更改颜色时,请确保单击颜色组合框的左侧,以便显示颜色选择器。 There, you'll have to change the Opacity to 0. 在那里,你必须将不透明度改为0。

See the image below for a simple demo. 有关简单演示,请参见下图。 替代文字

Good luck with your button 祝你的按钮好运

Chek out the the bottom corners of the reset button are rounded and transparent. 切出重置按钮的底角是圆形和透明的。 also set the backcolor of the button as clearcolor. 还将按钮的背景颜色设置为clearcolor。 and make the button custom instead of roundedrect. 并使按钮自定义而不是圆角。

I suppose the bottom corners of the buton are not transparent so you are facing the problem. 我想Buton的底角不透明,所以你面临的问题。

hAPPY cODING... 快乐的编码......

An easier solution may be to use something the Three20 framework. 一个更简单的解决方案可能是使用Three20框架。 It will allow you to create buttons like that (in addition to other styles) without images. 它允许您创建没有图像的按钮(除了其他样式)。

What kind of image do you using for that button, is there alpha channel? 你使用什么样的图像为那个按钮,有alpha通道吗? Also you could try something like this: 你也可以试试这样的东西:

yourButton.layer.cornerRadius = 15; // play with this value
yourButton.layer.masksToBounds = YES;

如何不设置按钮的背景图像,而是将带有所需图像的UIImageView直接放在按钮后面?

Chek out the the image of the reset button you are using is it in .png format and the image back color is clear color. 你正在使用的重置按钮的图像是.png格式,图像背面颜色是清晰的颜色。 If the problem persists please again make the image you are using there may be some problem with the image you used. 如果问题仍然存在,请再次使您正在使用的图像可能与您使用的图像有问题。

Check out this blog post: http://www.mlsite.net/blog/?p=232 看看这篇博文: http ://www.mlsite.net/blog/?p = 232

It has sources for a UIButton+glossy category that allows you to create glossy buttons in apple style. 它有UIButton +光泽类别的来源,允许您创建苹果风格的光泽按钮。 They look pretty much exactly like your buttons. 它们看起来非常像你的按钮。 And you wouldn't need to use images at all. 而且你根本不需要使用图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM