---
title: "How to set UIButton state in iOS"  
description: "How to set UIButton state in iOS"  
author: "marcel ethan"  
published: 2015-12-19  
updated: 2016-01-07  
canonical: https://www.mindstick.com/forum/33752/how-to-set-uibutton-state-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# How to set UIButton state in iOS

I have created a UIButton on our [iPhone app](https://www.mindstick.com/articles/208914/4life-innovations-is-bracing-up-to-acquire-ios-13-for-iphone-app-development), [now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now) I want to manually change the [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) state.\
I read the UIButton [documentation](https://answers.mindstick.com/qa/30462/what-is-documentation) but I can't seem to find anything about manually setting a UIButton state.\
Any help would be appreciated.

## Replies

### Reply by Tarun Kumar

We can set UIButton state by mannually.\
use code like this:\

```
UIButton *myButton=[UIButton buttonWithType : UIButtonTypeCustom];if(myButton isselected]){    myButton.selected=FALSE;}else{    myButton.selected=TRUE;}
```

Now, we can do operation on UIButton as requirement, like executing some action when button is selected and while not selected.\
\


---

Original Source: https://www.mindstick.com/forum/33752/how-to-set-uibutton-state-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
