我们使用下面这个图片作为按钮图片,这个图片的边缘没有任何白色的像素

但是最后显示的效果确是

这是放大后的效果,实际效果就是显示出两个很醒目的白点,我不知道这两个白点是如何出现的,原图中并没有
UIImage *btnImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"button-add" ofType:@"png"]]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.bounds = CGRectMake(0, 0, btnImage.size.width, btnImage.size.height); [btn setImage:faceImage forState:UIControlStateNormal];
以上是我用来画按钮的代码,是否针对透明的png图片,还有一些特殊的设置?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
UIButton *btn = [[UIButton alloc] initWithFrame: CGRectMake(0, 0, btnImage.size.width, btnImage.size.height)]; [btn setImage:faceImage forState:UIControlStateNormal];Frame在最开始的时候弄进去,不要后来设置bounds