开发者

Enlarging image with a button?

开发者 https://www.devze.com 2023-04-02 04:18 出处:网络
-(IBAction)bigger { must.bounds.size = CGSizeMake(must.bounds.size.width +5.0 , must.bounds.size.height +5.0);
-(IBAction)bigger {

    must.bounds.size = CGSizeMake(must.bounds.size.width +5.0 , must.bounds.size.height +5.0);  
}

This is the code I input but I get the error saying that the expression is not assignable. Must is a uiimageview. I want to make each property (height an开发者_如何学运维d width) bigger by 5.0 each time i press the button. How can i do this.


What you probably want is to set the frame instead of the bounds. Do something like:

CGRect frame = must.frame;
frame.size.width += 5;
frame.size.height += 5;
must.frame = frame;


//here u can get the image as bigger without moving its center point


-(IBAction)bigger {


    CGRect _bounds = must.bounds;

    CGPoint centerPoint=must.center;

    _bounds.size = CGSizeMake(must.bounds.size.width + 5.0 , must.bounds.size.height + 5.0);

    must.bounds = _bounds;

    must.center = centerPoint;



}
0

精彩评论

暂无评论...
验证码 换一张
取 消