https://github.com/devxoul/uibutton-backgroundcontentmode
A missing background content mode for UIButton.
https://github.com/devxoul/uibutton-backgroundcontentmode
Last synced: 3 months ago
JSON representation
A missing background content mode for UIButton.
- Host: GitHub
- URL: https://github.com/devxoul/uibutton-backgroundcontentmode
- Owner: devxoul
- License: mit
- Created: 2015-11-26T08:31:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-26T10:04:16.000Z (over 9 years ago)
- Last Synced: 2025-04-11T07:12:23.668Z (3 months ago)
- Language: Objective-C
- Size: 278 KB
- Stars: 22
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
UIButton+BackgroundContentMode
==============================[](https://cocoapods.org/pods/UIButton%2BBackgroundContentMode)
A missing background content mode for UIButton.
When to use?
------------
Let's assume that we have to set background image of UIButton. Like this:
```objc
[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](http://cocoapods.org).
```ruby
pod 'UIButton+BackgroundContentMode', '~> 0.1'
```Usage
-----Import `UIButton+BackgroundContentMode`, then set `backgroundContentMode` of UIButton.
For example:
![]()
```objc
button.backgroundContentMode = UIViewContentModeScaleAspectFit;
```
![]()
```objc
button.backgroundContentMode = UIViewContentModeScaleAspectFill;
```
Finish! Set background image and enjoy coding. :tada:
License
-------UIButton+BackgroundContentMode is under MIT license. See the [LICENSE](LICENSE) file for more info.