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
// | |
// StringExtensions.swift | |
// PlistSwift | |
// | |
// Created by aybek can kaya on 16/01/16. | |
// Copyright © 2016 aybek can kaya. All rights reserved. | |
// | |
import Foundation |
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
extension UIView { | |
func animateLoading () { | |
let gradient = CAGradientLayer() | |
gradient.startPoint = CGPoint(x: 0, y: 0) | |
gradient.endPoint = CGPoint(x: 1, y: 0) | |
gradient.frame = CGRect(x: 0, y: 0, width: self.bounds.size.width*3, height: self.bounds.size.height) | |
let lowerAlpha: CGFloat = 0.75 | |
let solid = UIColor(white: 1, alpha: 1).cgColor | |
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
// | |
// CollectionView.swift | |
// Trendyol | |
// | |
// Created by aybek can kaya on 12/06/2018. | |
// Copyright © 2018 aybek can kaya. All rights reserved. | |
// | |
import UIKit |
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
protocol ComponentIdentifier: class { | |
static var identifier: String { get } | |
} | |
extension ComponentIdentifier { | |
static var identifier: String { return String(describing: self) } | |
} | |
extension UIView { |
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
typealias NetworkResponse = (data:JSON? , error:NetworkError?) | |
enum NetworkError { | |
case userNotFound | |
case cannotGetUserId | |
case cannotGetServerResponse | |
case unknownError | |
func stringify()->String { | |
switch self { |
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
public extension UIColor { | |
public convenience init(hex: Int, alpha: CGFloat = 1.0) { | |
let red = CGFloat((hex & 0xFF0000) >> 16) / 255.0 | |
let green = CGFloat((hex & 0xFF00) >> 8) / 255.0 | |
let blue = CGFloat((hex & 0xFF)) / 255.0 | |
self.init(red: red, green: green, blue: blue, alpha: alpha) | |
} | |
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
enum AppFont { | |
case regularFont | |
case boldFont | |
case italicBoldFont | |
case italicFont | |
func font(size:CGFloat)->UIFont { | |
switch self { | |
case .boldFont: return UIFont(name: "Arial-BoldMT", size: size)! | |
case .italicBoldFont: return UIFont(name: "Arial-BoldItalicMT", size: size)! |
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
extension String { | |
func height(withConstrainedWidth width: CGFloat, font: UIFont) -> CGFloat { | |
let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude) | |
let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSAttributedStringKey.font: font], context: nil) | |
return ceil(boundingBox.height) | |
} | |
func width(withConstrainedHeight height: CGFloat, font: UIFont) -> CGFloat { | |
let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height) |
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
extension Int { | |
static func randomNumber(min:Int , max:Int)->Int { | |
var minimum = min | |
var maximum = max | |
if minimum < 0 { minimum = 0 } | |
if maximum < 0 { maximum = 0 } | |
if minimum == maximum { return minimum } | |
else if minimum > maximum { return randomNumber(min:maximum , max:minimum) } | |
return minimum + Int(arc4random())%(maximum - minimum) | |
} |
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
enum NavigationBarType { | |
case closeOnRight | |
} | |
class BaseViewController: UIViewController { | |
fileprivate static let barButtonSize = CGSize(width: 30, height: 30) | |
fileprivate enum NavigationBarButtonType { | |
case closeBtn |
OlderNewer