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
// MARK: - textfield Delegate functions | |
// navigation through textfields with return key | |
func textFieldShouldReturn(_ textField: UITextField) -> Bool { | |
if textField == self.emailField { | |
self.passwordField.becomeFirstResponder() | |
}else if textField == self.passwordField{ | |
self.emailField.becomeFirstResponder() | |
} | |
return false | |
} |
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 UITextField { | |
func addRequiredAsterisk() { | |
let asterisk = UILabel() | |
let string = ("*" as NSString).range(of: "*") | |
asterisk.frame = CGRect.init(x: self.frame.size.width-5, y: self.frame.size.height/2, width: 10, height: 10) | |
let redAst = NSMutableAttributedString(string: "*", attributes: [.foregroundColor: UIColor.red]) | |
redAst.addAttribute(NSAttributedString.Key.font,value:UIFont.systemFont(ofSize: 12, weight: .regular), range: string) | |
asterisk.attributedText = redAst | |
self.addSubview(asterisk) |
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.UITextField | |
extension UITextField { | |
func underlined(color:UIColor){ | |
let border = CALayer() | |
let width = CGFloat(1.0) | |
border.borderColor = color.cgColor | |
border.frame = CGRect(x: 0, y: self.frame.size.height - width, width: self.frame.size.width, height: self.frame.size.height) | |
border.borderWidth = width | |
self.layer.addSublayer(border) |
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
// we need to implement this inside viewwillLayoutSubviews. to update the ui and make it works | |
// in this example in going to customize my 3rd tab bar item only | |
override func viewWillLayoutSubviews() { | |
// acess to list of tab bar items | |
if let items = self.tabBar.items { | |
// in each item we have a view where we find 2 subviews imageview and label | |
// in this example i would like to change | |
// access to item view | |
let viewTabBar = items[2].value(forKey: "view") as? 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
extension String { | |
var localized: String { | |
return NSLocalizedString(self, comment: "\(self)_comment") | |
} | |
func localized(_ args: [CVarArg]) -> String { | |
return localized(args) | |
} | |
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 | |
import ImageIO | |
extension UIImage { | |
public class func gifImageWithData(data: NSData) -> UIImage? { | |
guard let source = CGImageSourceCreateWithData(data, nil) else { | |
print("image doesn't exist") | |
return 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 | |
import WebKit | |
class PrivacyPolicyViewController: UIViewController,WKNavigationDelegate { | |
var webView: WKWebView! | |
@IBOutlet weak var containerView: UIView! | |
override func viewDidLoad() { |
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
// | |
// CustomSegmentedControl.swift | |
// coop | |
// | |
// Created by Ben Hassen on 2020. 02. 27.. | |
// Copyright © 2020. Ben Hassen. All rights reserved. | |
// | |
import UIKit | |
protocol CustomSegmentedControlDelegate:class { |
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
// | |
// UIViewExtension.swift | |
// coop | |
// | |
// Created by Ben Hassen on 2020. 02. 21.. | |
// Copyright © 2020. Ben Hassen. All rights reserved. | |
// | |
import UIKit |
OlderNewer