SkTextureGradient is a library that allows users to easily create and manipulate gradient textures in their iOS applications. With a simple API, developers can create stunning visual effects by blending multiple colors seamlessly.
Features
- Create gradient textures with ease
- Blend multiple colors seamlessly
- Control gradient direction and position
- Support for linear and radial gradients
- Customize gradient color stops
- Integration with Core Graphics APIs
Requirements
- iOS 10.0+
- Xcode 11.0+
- Swift 5.0+
Installation
CocoaPods
To integrate SkTextureGradient into your Xcode project using CocoaPods, simply add the following line to your Podfile:
pod 'SkTextureGradient'
Then run the command pod install
to download and install the library.
Manual
If you prefer not to use CocoaPods, you can manually add the SkTextureGradient library to your project. Here’s how:
- Download the latest release from the GitHub repository.
- Unzip the downloaded file.
- In Xcode, open your project and navigate to the target’s General settings tab.
- Drag and drop the SkTextureGradient framework folder into the “Frameworks, Libraries, and Embedded Content” section.
- Make sure to select “Copy items if needed” and add the framework to your target.
Usage
Import
import SkTextureGradient
Creating a Gradient Texture
To create a gradient texture, use the SkTextureGradient
class and its constructor. Specify the gradient type and the desired colors to create a visually appealing effect:
let gradient = SkTextureGradient(type: .linear, colors: [UIColor.red, UIColor.blue])
Customizing the Gradient
You can further customize the gradient by adjusting its direction, position, and color stops:
gradient.direction = .diagonal
gradient.position = CGPoint(x: 0.5, y: 0.5)
gradient.colorStops = [
SkTextureGradient.ColorStop(color: UIColor.red, position: 0.0),
SkTextureGradient.ColorStop(color: UIColor.green, position: 0.5),
SkTextureGradient.ColorStop(color: UIColor.blue, position: 1.0)
]
Using the Gradient
Once you have created and customized your gradient texture, you can use it in various ways. For example, you can apply it to a sprite node in SpriteKit:
let spriteNode = SKSpriteNode(texture: gradient.texture(size: CGSize(width: 200, height: 200)))
Documentation
For detailed information about SkTextureGradient and its API usage, refer to the official documentation.
License
SkTextureGradient is released under the MIT License.