我想为aUIButton设置图片和标题。当我使用按钮的背景图像时,这两个都可见。但是当我使用setImage方法时,标题就不再可见了。
[self setBackgroundColor:[UIColor clearColor]];
[self setTitleEdgeInsets:UIEdgeInsetsMake(0.0, 80.0, 0.0, 0.0)];
[self setTitle:@"Kansal Ji" forState:UIControlStateNormal];
[self setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[self.titleLabel setBackgroundColor:[UIColor blueColor]];
[self setImage:[UIImage imageNamed:@"categories.png"] forState:UIControlStateNormal];
[self.imageView setBackgroundColor:[UIColor greenColor]];
[self setImageEdgeInsets:UIEdgeInsetsMake(0.0, 0.0, 0.0,kWidthOfView(self)-kHeightOfView(self))];
self.clipsToBounds = YES;
请帮助解决此问题。以下代码在UIButton的子类中完成。