UIButton+BackgroundContentMode 0.1.0

UIButton+BackgroundContentMode 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2015

Maintained by Suyeol Jeon.


Downloads

Total4,188
Week305
Month695

Installs

Apps150
Apps WeekApps This Week 9
Test Targets8
Test WeekTests This week 2
powered by Segment

GitHub

Stars16
Watchers3
Forks3
Issues1
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 63


  • By
  • devxoul

A missing background content mode for UIButton.

When to use?

scale-to-fill

Let's assume that we have to set background image of UIButton. Like this:

[button setBackgroundImage:image forState:UIControlStateNormal];

Oh my god. Aspect ratio has broken. :weary:
It's time to use UIButton+BackgroundContentMode to keep background image aspect ratio.


Installation

Use CocoaPods.

pod 'UIButton+BackgroundContentMode', '~> 0.1'

Usage

Import UIButton+BackgroundContentMode, then set backgroundContentMode of UIButton.

For example:

aspect-fit

button.backgroundContentMode = UIViewContentModeScaleAspectFit;



aspect-fill

button.backgroundContentMode = UIViewContentModeScaleAspectFill;



Finish! Set background image and enjoy coding. :tada:

License

UIButton+BackgroundContentMode is under MIT license. See the LICENSE file for more info.