我想在UIButton的点击方法中在UIImageview.image中设置UIButton背景图像的图像。
-(void)Click_save:(UIButton *)sender
{
UIButton *btn = sender;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 60, 320, 600)];
[self.view addSubview:view];
UIImageView *imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 30, 300, 600)];
[view addSubview:imgview];
imgview.image = btn.imageView.image;
}
答案 0 :(得分:1)
您需要使用imageView的image
属性而不是backgroundColor
属性。您还需要使用按钮的imageForState:属性来获取图像。
使用:
imgview.image = [btn imageForState:UIControlStateNormal];