This file contains 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
import UIKit | |
extension UISegmentedControl { | |
func goVertical() { | |
self.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) | |
for segment in self.subviews { | |
for segmentSubview in segment.subviews { | |
if segmentSubview is UILabel { | |
(segmentSubview as UILabel).transform = CGAffineTransformMakeRotation(CGFloat(-M_PI_2)) | |
} |
This file contains 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
UIFont: family Thonburi | |
UIFont: font Thonburi-Bold | |
UIFont: font Thonburi | |
UIFont: font Thonburi-Light | |
UIFont: family Khmer Sangam MN | |
UIFont: font KhmerSangamMN | |
UIFont: family Snell Roundhand | |
UIFont: font SnellRoundhand-Black | |
UIFont: font SnellRoundhand-Bold | |
UIFont: font SnellRoundhand |
This file contains 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 saveImage(image: UIImage, name:String) { | |
let req = NSMutableURLRequest(url: NSURL(string:"http://127.0.0.1:3001/")! as URL) | |
let ses = URLSession.shared | |
req.httpMethod="POST" | |
req.setValue("application/octet-stream", forHTTPHeaderField: "Content-Type") | |
req.setValue(name, forHTTPHeaderField: "X-FileName") | |
let jpgData = UIImageJPEGRepresentation(image, 1.0) | |
req.httpBodyStream = InputStream(data: jpgData!) | |
let task = ses.uploadTask(withStreamedRequest: req as URLRequest) | |
task.resume() |
This file contains 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 startNumber = 240 | |
var timer = Timer() | |
func runTime() { | |
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: (#selector(ViewController.tTimer)), userInfo: nil, repeats: true) | |
} | |
@objc func tTimer() { | |
if startNumber > 0 { | |
startNumber -= 1 | |
numberLabel.text = String(startNumber) |
This file contains 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
// FAILURE | |
var array = [["name": "glen"]] | |
for item in array { | |
item["rank"] = "advanced" // Generates an @lvalue error | |
} | |
// Even though array is immutable, it's of type <Array<Dictionary<String,String>>, | |
// item is assigned by let automatically. | |