Set a button background image iPhone programmatically

后端 未结 8 442
无人及你
无人及你 2020-12-13 14:25

In Xcode, how do you set the background of a UIButton as an image? Or, how can you set a background gradient in the UIButton?

8条回答
  •  被撕碎了的回忆
    2020-12-13 15:09

    This will work

    UIImage *buttonImage = [UIImage imageNamed:@"imageName.png"];
    [btn setImage:buttonImage forState:UIControlStateNormal];
    [self.view addSubview:btn];
    

提交回复
热议问题