|
| 1 | +// |
| 2 | +// SVG+UIKit.swift |
| 3 | +// SwiftDraw |
| 4 | +// |
| 5 | +// Created by Daniel Sincere on 25/10/14. |
| 6 | +// Copyright 2020 Simon Whitty |
| 7 | +// |
| 8 | +// Distributed under the permissive zlib license |
| 9 | +// Get the latest version from here: |
| 10 | +// |
| 11 | +// https://github.com/swhitty/SwiftDraw |
| 12 | +// |
| 13 | +// This software is provided 'as-is', without any express or implied |
| 14 | +// warranty. In no event will the authors be held liable for any damages |
| 15 | +// arising from the use of this software. |
| 16 | +// |
| 17 | +// Permission is granted to anyone to use this software for any purpose, |
| 18 | +// including commercial applications, and to alter it and redistribute it |
| 19 | +// freely, subject to the following restrictions: |
| 20 | +// |
| 21 | +// 1. The origin of this software must not be misrepresented; you must not |
| 22 | +// claim that you wrote the original software. If you use this software |
| 23 | +// in a product, an acknowledgment in the product documentation would be |
| 24 | +// appreciated but is not required. |
| 25 | +// |
| 26 | +// 2. Altered source versions must be plainly marked as such, and must not be |
| 27 | +// misrepresented as being the original software. |
| 28 | +// |
| 29 | +// 3. This notice may not be removed or altered from any source distribution. |
| 30 | +// |
| 31 | + |
| 32 | +#if canImport(UIKit) |
| 33 | +public import UIKit |
| 34 | + |
| 35 | +public extension UIGraphicsImageRendererContext { |
| 36 | + func draw(_ svg: SVG, in rect: CGRect? = nil) { |
| 37 | + self.cgContext.draw(svg, in: rect ) |
| 38 | + } |
| 39 | + |
| 40 | + func draw(_ svg: SVG, in rect: CGRect, byTiling: Bool) { |
| 41 | + self.cgContext.draw(svg, in: rect, byTiling: byTiling) |
| 42 | + } |
| 43 | + |
| 44 | + func draw( |
| 45 | + _ svg: SVG, |
| 46 | + in rect: CGRect, |
| 47 | + capInsets: (top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat), |
| 48 | + byTiling: Bool |
| 49 | + ) { |
| 50 | + self.cgContext.draw(svg, in: rect, capInsets: capInsets, byTiling: byTiling) |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +#endif |
0 commit comments