added iOS source code
[wl-app.git] / iOS / Pods / FolioReaderKit / Source / QuoteImage.swift
1 //
2 //  QuoteImage.swift
3 //  FolioReaderKit
4 //
5 //  Created by Heberti Almeida on 8/31/16.
6 //  Copyright (c) 2016 Folio Reader. All rights reserved.
7 //
8
9 import UIKit
10
11 /**
12  Defines a custom Quote image, can be a square `UIImage`, solid `UIColor` or `CAGradientLayer`.
13  */
14 public struct QuoteImage {
15     public var image: UIImage!
16     public var alpha: CGFloat!
17     public var textColor: UIColor!
18     public var backgroundColor: UIColor!
19     
20     /**
21      Quote image from `UIImage`
22      
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.
27      
28      - returns: A newly initialized `QuoteImage` object.
29      */
30     public init(withImage image: UIImage, alpha: CGFloat = 1, textColor: UIColor = UIColor.white, backgroundColor: UIColor = UIColor.white) {
31         self.image = image
32         self.alpha = alpha
33         self.textColor = textColor
34         self.backgroundColor = backgroundColor
35     }
36     
37     /**
38      Quote image from `CAGradientLayer`
39      
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.
44      
45      - returns: A newly initialized `QuoteImage` object.
46      */
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)
51         self.alpha = alpha
52         self.textColor = textColor
53         self.backgroundColor = backgroundColor
54     }
55     
56     /**
57      Quote image from `UIColor`
58      
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.
63      
64      - returns: A newly initialized `QuoteImage` object.
65      */
66     public init(withColor color: UIColor, alpha: CGFloat = 1, textColor: UIColor = UIColor.white, backgroundColor: UIColor = UIColor.white) {
67         self.image = UIImage.imageWithColor(color)
68         self.alpha = alpha
69         self.textColor = textColor
70         self.backgroundColor = backgroundColor
71     }
72 }