Skip to content

Instantly share code, notes, and snippets.

Alexander Tikhonov TikhonovAlexander

Block or report user

Report or block TikhonovAlexander

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
TikhonovAlexander / BlackOrWhite.swift
Created Feb 19, 2019
BlackOrWhite text color depending on the backgroundColor
View BlackOrWhite.swift
// Color.swift
// Created by Aleksandr Tikhonov on 19.02.19.
// Copyright © 2019 tikhonov. All rights reserved.
import UIKit
extension UIColor {
View TextAsMaskLayer.swift
let image = UIGraphicsImageRenderer(size: bounds.size).image { _ in
text.draw(in: bounds, withAttributes: textAttributes)
let maskLayer = CALayer()
maskLayer.backgroundColor = UIColor.clear.cgColor
maskLayer.frame = bounds.offsetBy(dx: bounds.size.width, dy: 0)
maskLayer.contents = image.cgImage
gradientLayer.mask = maskLayer
TikhonovAlexander / EmailValidator.swift
Last active Dec 20, 2015
Validation of email string Swift
View EmailValidator.swift
class SGValidator {
static func isValidEmail(string:String) -> Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return emailTest.evaluateWithObject(string)
You can’t perform that action at this time.