我尝试UIButton
在文本上方制作一个带有图像的图像,所以我使用以下代码:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(x, y, 140, 140);
[btn setTitle:self.objMateria.titoloMateria forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[btn setBackgroundColor:[UIColor clearColor]];
[btn setImage:[UIImage imageNamed:@"pala.png"] forState:UIControlStateNormal];
btn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 20, 0);
btn.titleEdgeInsets = UIEdgeInsetsMake(120, 0, 0, 0);
问题是这段代码我看不到文字,似乎被图像覆盖了,错误在哪里?
这里的图像: