## CRPixellatedView
CRPixellatedView is a lightweight and easy-to-use UIView subclass that allows you to apply pixelation effect to any image or view.
## Features
– Apply pixelation effect to images or views
– Control pixelation level and aspect ratio
– Customize pixelation effect with different colors
– Easily add pixelation animation
## Installation
CRPixellatedView can be easily installed using Cocoapods. Simply add the following line to your Podfile:
“`ruby
pod ‘CRPixellatedView’
“`
Then run the command `pod install` to add the dependency to your project.
## Usage
Import the CRPixellatedView module in your .swift file where you want to use it:
“`swift
import CRPixellatedView
“`
### Creating a CRPixellatedView
To create a CRPixellatedView, you can either programmatically initialize it or add it directly in Interface Builder.
#### Programmatically
“`swift
let pixellatedView = CRPixellatedView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
“`
#### Interface Builder
– Drag and drop a UIView from the Object Library onto your storyboard.
– In the Identity Inspector, set the custom class as `CRPixellatedView`.
### Applying Pixelation Effect
To apply the pixelation effect, you can simply set the input image or view using the `image` or `viewToPixellate` property respectively.
“`swift
pixellatedView.image = UIImage(named: “your_image_name”)
// or
pixellatedView.viewToPixellate = yourView
“`
### Customizing the Pixelation Effect
CRPixellatedView provides several properties to customize the pixelation effect. Below are some common properties:
– `pixelationLevel`: Adjust the pixelation level (Default: 20.0)
– `gridColor`: Set color for the pixelation grid (Default: #000000)
– `gridWidth`: Set width of the pixelation grid lines (Default: 1.0)
– `gridCornerRadius`: Set corner radius of the pixelation grid (Default: 0.0)
You can modify these properties as needed:
“`swift
pixellatedView.pixelationLevel = 15.0
pixellatedView.gridColor = UIColor.blue
pixellatedView.gridWidth = 2.0
“`
### Adding Pixelation Animation
Pixelation animation can be added to make the effect more visually appealing. Use the `animatePixelation` method to add pixelation animation:
“`swift
pixellatedView.animatePixelation(duration: 2.0, delay: 0.5)
“`
### Removing the Pixelation Effect
To remove the pixelation effect, simply set the `image` or `viewToPixellate` property as `nil`:
“`swift
pixellatedView.image = nil
// or
pixellatedView.viewToPixellate = nil
“`
## Requirements
– iOS 9.0+
– Swift 4.0+
## Author
CRPixellatedView is developed and maintained by Your Name.
## License
CRPixellatedView is available under the MIT license. See the LICENSE file for more info.
## Conclusion
CRPixellatedView is a versatile and lightweight solution to apply pixelation effect to your images or views. With its customizable options and easy-to-use interface, it provides a seamless way to add visual effects to your iOS app. Give it a try and enhance your user experience!