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 | |
class NexorPageControl: UIPageControl { | |
fileprivate let activeDotFrame = CGRect(origin: .zero, size: CGSize(width: 21, height: 7)) | |
fileprivate let inactiveDotFrame = CGRect(origin: .zero, size: CGSize(width: 7, height: 7)) | |
fileprivate let dotPadding: CGFloat = 9 //default is 9 | |
lazy var activeImage: UIImage = { | |
let view = UIView(frame: self.activeDotFrame) |
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 prepareNotification(content: UNNotificationContent, userInfo: [AnyHashable: Any], completionHandler: @escaping (UNNotificationPresentationOptions) -> Void){ | |
// Register the notification type. | |
let notificationCenter = UNUserNotificationCenter.current() | |
var json = JSON(userInfo) | |
guard let data = json["data"].dictionary else { | |
completionHandler([ .alert, .sound, .badge ]) | |
return | |
} |
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
{ | |
"aps": { | |
"alert": { | |
"title": "www.nexor.it", | |
"body": "Rispondi a questo interessante sondaggio" | |
}, | |
"sound": "default", | |
"mutable-content": 1 | |
}, | |
"data": { |
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
let color = UIColor(named: "background") //always works |
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
let image = UIImage(named: "background") |
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
//Need an imageRef error | |
let image = UIImage(named: "background") //works only if an image named "background" exists else crash! | |
let color = UIColor(named: "background") //always works |
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
class LabelBody: LabelTappable { | |
var body: String? { | |
get { | |
return self.attributedText?.string | |
} | |
set { | |
self.text = nil | |
guard let text = newValue, !text.isEmpty else { | |
self.attributedText = nil |
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 | |
class LabelTappable: UILabel { | |
let layoutManager = NSLayoutManager() | |
let textContainer = NSTextContainer(size: CGSize.zero) | |
let tapGesture = UITapGestureRecognizer() | |
var textStorage = NSTextStorage() { | |
didSet { |
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 String { | |
func html(font: UIFont) -> NSAttributedString? { | |
do { | |
let modifiedText = String(format: "<span style=\"font-family: \(font.fontName); font-size: \(font.pointSize)\">%@</span>", self) as String | |
let attrStr = try NSAttributedString( | |
data: modifiedText.data(using: String.Encoding.unicode, allowLossyConversion: true)!, | |
options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue], |
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
https://samples.openweathermap.org/data/2.5/forecast/daily?q=München,DE&appid=b6907d289e10d714a6e88b30761fae22 | |
https://openweathermap.org/forecast16#name16 | |
http://openweathermap.org/img/w/ |
NewerOlder