UIButton+BackgroundContentMode 0.1.0

UIButton+BackgroundContentMode 0.1.0

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

Maintained by Suyeol Jeon.


Downloads

Total2,374
Week78
Month172

Installs

Apps116
Apps WeekApps This Week 11
Test Targets7
Test WeekTests This week 2
powered by Segment

GitHub

Stars11
Watchers2
Forks1
Issues1
Contributors1
Pull Requests0

Code

Files2
SizeIntegration Size 16 kb
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.