5 // Created by Heberti Almeida on 8/31/16.
6 // Copyright (c) 2016 Folio Reader. All rights reserved.
12 Defines a custom Quote image, can be a square `UIImage`, solid `UIColor` or `CAGradientLayer`.
14 public struct QuoteImage {
15 public var image: UIImage!
16 public var alpha: CGFloat!
17 public var textColor: UIColor!
18 public var backgroundColor: UIColor!
21 Quote image from `UIImage`
23 - parameter image: An `UIImage` to be used as background.
24 - parameter alpha: The image opacity. Defaults to 1.
25 - parameter textColor: The color of quote text and custom logo. Defaults to white.
26 - parameter backgroundColor: The filter background color, if the image has a opacity this will appear. Defaults to white.
28 - returns: A newly initialized `QuoteImage` object.
30 public init(withImage image: UIImage, alpha: CGFloat = 1, textColor: UIColor = UIColor.white, backgroundColor: UIColor = UIColor.white) {
33 self.textColor = textColor
34 self.backgroundColor = backgroundColor
38 Quote image from `CAGradientLayer`
40 - parameter gradient: A custom `CAGradientLayer` to make a gradient background.
41 - parameter alpha: The image opacity. Defaults to 1.
42 - parameter textColor: The color of quote text and custom logo. Defaults to white.
43 - parameter backgroundColor: The filter background color, if the image has a opacity this will appear. Defaults to white.
45 - returns: A newly initialized `QuoteImage` object.
47 public init(withGradient gradient: CAGradientLayer, alpha: CGFloat = 1, textColor: UIColor = UIColor.white, backgroundColor: UIColor = UIColor.white) {
48 let screenBounds = UIScreen.main.bounds
49 gradient.frame = CGRect(x: 0, y: 0, width: screenBounds.width, height: screenBounds.width)
50 self.image = UIImage.imageWithLayer(gradient)
52 self.textColor = textColor
53 self.backgroundColor = backgroundColor
57 Quote image from `UIColor`
59 - parameter color: A custom `UIColor`
60 - parameter alpha: The image opacity. Defaults to 1.
61 - parameter textColor: The color of quote text and custom logo. Defaults to white.
62 - parameter backgroundColor: The filter background color, if the image has a opacity this will appear. Defaults to white.
64 - returns: A newly initialized `QuoteImage` object.
66 public init(withColor color: UIColor, alpha: CGFloat = 1, textColor: UIColor = UIColor.white, backgroundColor: UIColor = UIColor.white) {
67 self.image = UIImage.imageWithColor(color)
69 self.textColor = textColor
70 self.backgroundColor = backgroundColor