Custom UIButton with Highlighted Background in Xcode

Learn to customize UIButton's highlighted state with background images for a better UI in Xcode. 🎨

Custom UIButton with Highlighted Background in Xcode
Paul Solt
20.0K views • Jul 17, 2014
Custom UIButton with Highlighted Background in Xcode

About this video

4/5 Custom UIButton with Highlighted Background Images in Xcode

You can customize the press state, also known as the highlighted state of your UIButton. Change your button type from System to Custom in Interface Builder.

Part 1/5: https://www.youtube.com/watch?v=waKXlYQHGlA
Part 2/5: https://www.youtube.com/watch?v=AdOUVC_wJmw
Part 3/5: https://www.youtube.com/watch?v=v2AZ0JgKhQU
Part 4/5: https://www.youtube.com/watch?v=xzttkcAQlK8
Part 5/5: https://www.youtube.com/watch?v=It3dsnGhhLo

After you change it you'll be responsible for setting the title text color, keeping the button in-sync with the view's tint color, animating it, and changing the font size from 18 to 15 (to match system button styles).

Add code to make the button animate and fit in with iOS 7 and iOS 8 button styles, and you can still have full control of the button border graphic.

- (void)viewDidLoad {
[super viewDidLoad];

// Add a fade animation
[self.button addTarget:self action:@selector(buttonTouchDown:) forControlEvents:UIControlEventTouchDown];
[self.button addTarget:self action:@selector(buttonTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)buttonTouchDown:(UIButton *)button {
button.titleLabel.alpha = 0.15;
}

- (void)buttonTouchUpInside:(UIButton *)button {
[UIView animateWithDuration:0.3 animations:^{
button.titleLabel.alpha = 1.0;
}];
}

Click here to Subscribe to learn how to make iPhone apps. http://www.youtube.com/subscription_center?add_user=PaulSolt

Links:
Blog: http://iPhoneDev.tv
iPhone Courses: http://learn.iphonedev.tv/course/iPhoneGoldSubscription/

Contact:
YouTube Channel: https://www.youtube.com/user/paulsolt
Twitter: http://Twitter.com/PaulSolt
Facebook: http://Facebook.com/PaulSolt
Google+: https://plus.google.com/u/0/+PaulSoltInc
Paul's iPhone Apps: http://AppStore.com/PaulSolt

Tags and Topics

Browse our collection to discover more content in these categories.

Video Information

Views

20.0K

Likes

42

Duration

11:52

Published

Jul 17, 2014

User Reviews

3.9
(4)
Rate:

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.

Trending Now