This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let mainLayer = CALayer() | |
| mainLayer.frame = CGRect(x: 0, y: 0, width: 500, height: 500) | |
| mainLayer.backgroundColor = CGColor(red: 100.0/255.0, green: 130.0/255.0, blue: 230.0/255.0, alpha: 1.0) | |
| let layer = CALayer() | |
| layer.frame = CGRect(x: 250, y: 250, width: 100, height: 100) | |
| layer.backgroundColor = CGColor(srgbRed: 10.0, green: 50.0, blue: 10.0, alpha: 100.0) | |
| let oneLayer = CALayer() | |
| oneLayer.frame = CGRect(x: 300, y: 300, width: 50, height: 50) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func lines(space: Int, context: CGRect, count: Int) -> [CGRect] { | |
| var line = [CGRect]() | |
| for arr in 0..<count { | |
| let lineOne = CGRect(origin:context.minX + CGRect(space) * CGRect(arr), | |
| size: context.height) | |
| let lineOtwo = CGRect(origin:context.width, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func makePlus(at point: CGPoint, dimension: CGFloat, thickness: CGFloat) -> [CGRect] { | |
| let width = dimension | |
| let height = thickness | |
| let first = CGRect( | |
| x: point.x - dimension / 2 , | |
| y: point.y - thickness / 2, | |
| width: width, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func rectangles( largeRect: CGRect, count: Int) -> [CGRect] { | |
| if count <= 1 { | |
| CGRect(x: 0, y: 0, width: largeRect.width , height: largeRect.height) | |
| return [] | |
| } else { | |
| for _ in 0...count{ | |
| CGRect(x: (0 + (largeRect.width)) * CGFloat(count) , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func rectangles( largeRect: CGRect, count: Int) -> [CGRect] { | |
| if count <= 1 { | |
| CGRect(x: 0, y: 0, width: largeRect.width , height: largeRect.height) | |
| return [] | |
| } else { | |
| for _ in 0...count{ | |
| CGRect(x: 0 + (largeRect.width) * CGFloat(count) , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func rectangles( largeRect: CGRect, count: Int) -> [CGRect] { | |
| if count <= 1 { | |
| CGRect(x: 0, y: 0, width: largeRect.width , height: largeRect.height) | |
| return [] | |
| } else { | |
| for _ in 0...count{ | |
| CGRect(x: 0 + (largeRect.width) * CGFloat(count) , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Siblings { | |
| var sibling1: Int | |
| var sibling2: Int | |
| init(sibling1: Int, sibling2: Int){ | |
| self.sibling1 = sibling1 | |
| self.sibling2 = sibling2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Siblings { | |
| var sibling1: Int | |
| var sibling2: Int | |
| init(sibling1: Int, sibling2: Int){ | |
| self.sibling1 = sibling1 | |
| self.sibling2 = sibling2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func swapTwoString(a: inout String, b: inout String) { | |
| let temporaryB = a | |
| a = b | |
| b = temporaryB | |
| } | |
| var someString = "I AM FIRST" | |
| var anotherStirng = "I AM SECONDE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ["One", "Two", "Three"] | |
| array.append("Four") | |
| // This won't compile, since the above array is specialized | |
| // for strings, meaning that other values can't be inserted: | |
| array.append(5) | |
| // As we pull an element out of the array, we can still treat | |
| // it like a normal string, since we have full type safety. | |
| let characterCount = array[0].count |