pear-uicolorextention-ios
pear-uicolorextention-ios is a library that extends the functionality of UIColor in iOS development. It provides additional methods and utilities to easily manipulate colors and create custom color palettes.
Features
- Extensions to UIColor for easy color manipulation
- Create gradient colors
- Generate random colors
- Convert between color representations (RGB, HSB, hexadecimal)
- Custom color palettes
Installation
To install pear-uicolorextention-ios, simply include the following line in your Podfile:
pod 'pear-uicolorextention-ios'
Usage
UIColor Extensions
The library adds several extensions to UIColor to easily manipulate colors:
// Create a UIColor instance from hexadecimal representation
let color = UIColor(hex: "#FF0000")
// Adjust brightness of a color
let adjustedColor = color.adjustBrightness(by: -0.2)
// Blend two colors
let blendedColor = color.blend(with: UIColor.blue)
// Generate a random color
let randomColor = UIColor.random()
Gradient Colors
The library allows you to create gradient colors by specifying an array of colors to blend:
// Create a gradient color
let gradientColors = [UIColor.red, UIColor.yellow, UIColor.green]
let gradient = UIColor.gradient(from: gradientColors, locations: nil, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 1, y: 1))
Color Conversion
You can easily convert between different color representations:
// Convert UIColor to hexadecimal string
let hexString = color.toHexString() // e.g. "#FF0000"
// Convert hexadecimal string to UIColor
let convertedColor = UIColor(hex: hexString)
// Get RGB or HSB components of a color
let rgbComponents = color.getRGBComponents()
let hsbComponents = color.getHSBComponents()
Custom Color Palettes
The library provides utilities to create and manage custom color palettes:
// Create a color palette
let colorPalette = ColorPalette()
// Add colors to the palette
colorPalette.add(color: UIColor.red)
colorPalette.add(color: UIColor.blue)
colorPalette.add(color: UIColor.green)
// Get all colors in the palette
let allColors = colorPalette.getAllColors()
// Get a random color from the palette
let randomPaletteColor = colorPalette.getRandomColor()
Documentation
For detailed documentation and usage examples, refer to the GitHub repository.
License
pear-uicolorextention-ios is released under the MIT license. See LICENSE for more details.
Contact
If you have any questions or suggestions, feel free to contact the developers at info@pearapps.com.