Skip to content

Instantly share code, notes, and snippets.

View illescasDaniel's full-sized avatar
💻
Learning something new

Daniel Illescas Romero illescasDaniel

💻
Learning something new
View GitHub Profile
@illescasDaniel
illescasDaniel / SlideAnimationTabBarController.swift
Last active April 11, 2022 14:03 — forked from benvium/MyTabBar.m
[Updated to Swift 4] - UITabBarController slide animation. Slide left and right when tabs are selected. Based on code from StackOverflow
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if let fromView = tabBarController.selectedViewController?.view,
let toView = viewController.view, fromView != toView,
let controllerIndex = self.viewControllers?.index(of: viewController) {
let viewSize = fromView.frame
let scrollRight = controllerIndex > tabBarController.selectedIndex
// Avoid UI issues when switching tabs fast
@illescasDaniel
illescasDaniel / String+Email.swift
Last active March 26, 2017 21:18 — forked from DaveWoodCom/String+Email.swift
Swift method to check for a valid email address (uses Apples data detector instead of a regex)
import Foundation
extension String {
mutating func isValidEmail() -> Bool {
guard !self.lowercased().hasPrefix("mailto:") else { return false }
guard let emailDetector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) else { return false }