Create complementary gradients generated from dominant and prominent colors in supplied image. Inspired by Grade.js ❤️
allColors/left | primaryBackground/top |
---|---|
detailBackground/top | secondaryBackground/bottom |
---|---|
ComplimentaryGradientView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ComplimentaryGradientView'
pod 'ComplimentaryGradientView', '~> 0.1.0'
Download and drop ComplimentaryGradientView.xcodeproj
into your project
OR
Drag Source
folder into your project.
let gradientView = ComplimentaryGradientView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
//Colors for gradient are derived from the provided image
gradientView.image = UIImage(named: "myImg")
//Default = .backgroundPrimary (See GradientType enum for all possible values)
gradientView.gradientTpye = .backgroundPrimary
//Defaut = .Top. Possible values = Ttp, left, right, bottom
gradientView.gradientStartPoint = .left
optional func complimentaryGradientView(didSetGradient gradientView: ComplimentaryGradientView, gradientSet: Bool)
public enum GradientType: String {
//background
case backgroundPrimary
case backgroundSecondary
case backgroundDetail
//primary
case primaryBackground
case primarySecondary
case primaryDetail
//secondary
case secondaryBackground
case secondaryPrimary
case secondaryDetail
//detail
case detailBackground
case detailPrimary
case detailSecondary
//AllColors
case allColors
}
ComplimentaryGradientView is available under the MIT license. See the LICENSE file for more info.