
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Customise iOS Button to Set Text and Color
In this post we will be seeing how to customise iOS button.
So let’s get started.
Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “CustomiseButton”
Step 2− Open Main.storyboard and add a button as shown below. We will customize this button
There are two ways to customise this button
- Using Storyboard
- Step 1 − Click on the button
- Step 2 − In the right panel, in the attribute inspector you can change the text color, text and background color of the button as shown below
Run the project you will see the customise button as below
Now we will see the second way to customise the button
- Programmatically Customise the button
- Step 1 − Create @IBOutlet for the button, name it customButton.
- Step 2 − In viewDidLoad method customise the button as follows
override func viewDidLoad() { super.viewDidLoad() customButton.setTitle("My Custom Button", for: .normal) customButton.backgroundColor = UIColor.green }
Run the project, you see the customised button as shown below
Advertisements