Search code examples
framensbutton

Change Button Width and Height Programmatically Xcocde


I have an app that you tap a button and at certain points you get time added. I want to add to the app that whenever the certain point is met, the button height and width get smaller. How would I go about doing that?


Solution

  • If your button is named, say, button, this will make it 5 pixels smaller in all directions:

    [button setFrame:CGRectInset(button.frame, 5, 5);
    

    You can have more freedom by using any CGRect value you wish; but setFrame is the way to go.