Skip to content

Instantly share code, notes, and snippets.

View numanayhan's full-sized avatar
🏈
Coding

Numan Ayhan numanayhan

🏈
Coding
  • Istanbul
View GitHub Profile
@numanayhan
numanayhan / UILabelSize.swift
Created June 11, 2023 09:22 — forked from fuxingloh/UILabelSize.swift
iOS Swift: How to find text width, text height or size of UILabel.
extension UILabel {
func textWidth() -> CGFloat {
return UILabel.textWidth(label: self)
}
class func textWidth(label: UILabel) -> CGFloat {
return textWidth(label: label, text: label.text!)
}
class func textWidth(label: UILabel, text: String) -> CGFloat {
@numanayhan
numanayhan / CoreTelephonyCheck.swift
Created October 29, 2022 15:13 — forked from krin-san/CoreTelephonyCheck.swift
Check if iOS device is capable to call / send SMS message
// Swift version of the code from http://stackoverflow.com/a/30335594/1986600
import CoreTelephony
override func awakeFromNib() {
super.awakeFromNib()
let isCapableToCall: Bool
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "tel://")!) {
// Check if iOS Device supports phone calls
func validate(response: HTTPResponse, forRequest request: HTTPRequest) -> HTTPResponseValidatorResult {
if !(200..<300).contains(response.statusCode) {
// invalid response, we want to fail the request with error
throw HTTPError.invalidResponse
}
return .nextValidator // everything is okay, move to next validator
}
@numanayhan
numanayhan / iterm2-solarized.md
Created November 29, 2021 10:50 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k