Setting Background image of button as a Image view Image
I'v an application in which i want to set the image of my image view same as my button, which is been clicked.. i'm using this code;
mainSlideShowImageView.image=((UIButton *)sende开发者_StackOverflowr).image;
but there is Error..
65: error: request for member 'image' in something not a structure or union
what is other way to do So?
[(UIButton *)sender imageForState:UIControlStateNormal];
or, if it's a background image, backgroundImageForState:
.
Try using currentImage or currentBackgroundImage like so:
UIButton *ad = [[UIButton alloc] initWithFrame:CGRectZero];
UIImageView *iV = [[UIImageView alloc] initWithImage:ad.currentBackgroundImage];
or
UIButton *ad = [[UIButton alloc] initWithFrame:CGRectZero];
UIImageView *iV = [[UIImageView alloc] initWithImage:ad.currentImage];
Try this
UIButton *button = (UIButton *)sender;
mainSlideShowImageView.image= button.currentImage;
精彩评论