dali
dali

Reputation: 164

Scale image to fit in UIButton

I have a problem with the UIButtons. How can I scale a image to fit their frame?

Upvotes: 1

Views: 1816

Answers (2)

dali
dali

Reputation: 164

Just needed to combine setbackgroundimage and set to fill

Upvotes: 1

Matrix
Matrix

Reputation: 7613

UIButton *Btn = [UIButton buttonWithType:UIButtonTypeCustom];
    Btn.frame = //set frame using CGRectMake(x,y,width,height);     
    [Btn setBackgroundImage:[UIImage imageNamed:@"image name here"] forState:UIControlStateNormal];

Upvotes: 2

Related Questions