From ac166de31de51de5358e1570369b31db7ed8530b Mon Sep 17 00:00:00 2001 From: hamed akhlaghi Date: Mon, 5 Nov 2018 10:40:15 +0330 Subject: [PATCH] Theme and style R&D results #9 --- MobileToken.xcodeproj/project.pbxproj | 16 ++++++ MobileToken/Info.plist | 4 ++ MobileToken/MyButton.swift | 54 +++++++++++++++++++ MobileToken/MyButton.xib | 27 ++++++++++ MobileToken/MyButton1.swift | 34 ++++++++++++ MobileToken/MyButton1.xib | 13 +++++ .../CustomColor.colorset/Contents.json | 20 +++++++ .../ui/viewcontroller/ViewController.swift | 10 +++- .../view/basic/Base.lproj/Main.storyboard | 19 +++++++ MobileToken/view/nibs/CardCell.xib | 4 +- 10 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 MobileToken/MyButton.swift create mode 100644 MobileToken/MyButton.xib create mode 100644 MobileToken/MyButton1.swift create mode 100644 MobileToken/MyButton1.xib create mode 100644 MobileToken/assets/Assets.xcassets/CustomColor.colorset/Contents.json diff --git a/MobileToken.xcodeproj/project.pbxproj b/MobileToken.xcodeproj/project.pbxproj index 7033c47..7641075 100644 --- a/MobileToken.xcodeproj/project.pbxproj +++ b/MobileToken.xcodeproj/project.pbxproj @@ -26,6 +26,10 @@ AFB9BB37218F105E004F16DD /* roboto.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AFB9BB34218F105E004F16DD /* roboto.ttf */; }; AFB9BB38218F105E004F16DD /* IranSansMediumEnglish.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AFB9BB35218F105E004F16DD /* IranSansMediumEnglish.ttf */; }; AFB9BB3A218F106E004F16DD /* IranSansReqular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AFB9BB39218F106D004F16DD /* IranSansReqular.ttf */; }; + AFB9BB3C218F1E52004F16DD /* MyButton.xib in Resources */ = {isa = PBXBuildFile; fileRef = AFB9BB3B218F1E52004F16DD /* MyButton.xib */; }; + AFB9BB3E218F1E8A004F16DD /* MyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFB9BB3D218F1E8A004F16DD /* MyButton.swift */; }; + AFB9BB42218F2B0A004F16DD /* MyButton1.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFB9BB41218F2B0A004F16DD /* MyButton1.swift */; }; + AFE190E6218F33060023E785 /* MyButton1.xib in Resources */ = {isa = PBXBuildFile; fileRef = AFE190E5218F33050023E785 /* MyButton1.xib */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -73,6 +77,10 @@ AFB9BB34218F105E004F16DD /* roboto.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = roboto.ttf; sourceTree = ""; }; AFB9BB35218F105E004F16DD /* IranSansMediumEnglish.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = IranSansMediumEnglish.ttf; sourceTree = ""; }; AFB9BB39218F106D004F16DD /* IranSansReqular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = IranSansReqular.ttf; sourceTree = ""; }; + AFB9BB3B218F1E52004F16DD /* MyButton.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MyButton.xib; sourceTree = ""; }; + AFB9BB3D218F1E8A004F16DD /* MyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyButton.swift; sourceTree = ""; }; + AFB9BB41218F2B0A004F16DD /* MyButton1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyButton1.swift; sourceTree = ""; }; + AFE190E5218F33050023E785 /* MyButton1.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MyButton1.xib; sourceTree = ""; }; E8A2288F27762FE7AA71A63C /* Pods-MobileTokenUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobileTokenUITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MobileTokenUITests/Pods-MobileTokenUITests.debug.xcconfig"; sourceTree = ""; }; EA1FA22EE60EF74C815B714D /* Pods_MobileToken.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MobileToken.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ED130E855374C06F3DA0E42E /* Pods-MobileTokenTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobileTokenTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MobileTokenTests/Pods-MobileTokenTests.debug.xcconfig"; sourceTree = ""; }; @@ -237,6 +245,10 @@ AF463BC32189D8DF00DC8A3E /* ui */, AF463BC22189D8CF00DC8A3E /* data */, AFB39B5B2189A6A700302624 /* Info.plist */, + AFE190E5218F33050023E785 /* MyButton1.xib */, + AFB9BB3B218F1E52004F16DD /* MyButton.xib */, + AFB9BB3D218F1E8A004F16DD /* MyButton.swift */, + AFB9BB41218F2B0A004F16DD /* MyButton1.swift */, ); path = MobileToken; sourceTree = ""; @@ -401,8 +413,10 @@ AFB9BB3A218F106E004F16DD /* IranSansReqular.ttf in Resources */, AFB9BB38218F105E004F16DD /* IranSansMediumEnglish.ttf in Resources */, AFB9BB36218F105E004F16DD /* IranSansMediumFarsi.ttf in Resources */, + AFE190E6218F33060023E785 /* MyButton1.xib in Resources */, AFB39B552189A6A600302624 /* Main.storyboard in Resources */, AFB9BB28218EE0D7004F16DD /* CardCell.xib in Resources */, + AFB9BB3C218F1E52004F16DD /* MyButton.xib in Resources */, AFB9BB37218F105E004F16DD /* roboto.ttf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -510,9 +524,11 @@ buildActionMask = 2147483647; files = ( AF463BCE218AD11900DC8A3E /* User.swift in Sources */, + AFB9BB3E218F1E8A004F16DD /* MyButton.swift in Sources */, AFB9BB2A218EFB42004F16DD /* CardCellXibView.swift in Sources */, AFB39B522189A6A600302624 /* ViewController.swift in Sources */, AF463BC92189DD4900DC8A3E /* RealmConfiguration.swift in Sources */, + AFB9BB42218F2B0A004F16DD /* MyButton1.swift in Sources */, AF463BD0218ADD8200DC8A3E /* Authentication.swift in Sources */, AFB39B502189A6A600302624 /* AppDelegate.swift in Sources */, ); diff --git a/MobileToken/Info.plist b/MobileToken/Info.plist index 16be3b6..eb92701 100644 --- a/MobileToken/Info.plist +++ b/MobileToken/Info.plist @@ -2,6 +2,10 @@ + UIAppFonts + + IranSansRegular.ttf + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable diff --git a/MobileToken/MyButton.swift b/MobileToken/MyButton.swift new file mode 100644 index 0000000..b8f0473 --- /dev/null +++ b/MobileToken/MyButton.swift @@ -0,0 +1,54 @@ +// +// MyButton.swift +// MobileToken +// +// Created by hamed akhlaghi on 8/13/1397 AP. +// Copyright © 1397 ba24.ir. All rights reserved. +// + +import Foundation +import UIKit + +@IBDesignable + +class MyButton: UIButton { + + // Connect the custom button to the custom class + @IBOutlet weak var view: UIButton! + + override init(frame: CGRect) { + super.init(frame: frame) + setup(nibName: "MyButton") + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setup(nibName: "MyButton") + } + + func setup(nibName:String) { + view = (loadViewFromNib(nibName: nibName) as! UIButton) + view.frame = bounds + + view.autoresizingMask = [UIView.AutoresizingMask.flexibleWidth, + UIView.AutoresizingMask.flexibleHeight] + + addSubview(view) + + // Add our border here and every custom setup + view.layer.borderWidth = 2 + view.layer.borderColor = UIColor.black.cgColor + view.titleLabel!.font = UIFont.systemFont(ofSize: 20) + } + + func loadViewFromNib(nibName:String) -> UIView! { + let bundle = Bundle(for: type(of: self)) + let nib = UINib(nibName: nibName, bundle: bundle) + let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIButton + let font = UIFont(name: "IranSansRegular.ttf", size: 85) + view.titleLabel?.font = font + setTitle("dssddsdsds", for: .normal) + return view + } + +} diff --git a/MobileToken/MyButton.xib b/MobileToken/MyButton.xib new file mode 100644 index 0000000..728ea8b --- /dev/null +++ b/MobileToken/MyButton.xib @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + diff --git a/MobileToken/MyButton1.swift b/MobileToken/MyButton1.swift new file mode 100644 index 0000000..1303283 --- /dev/null +++ b/MobileToken/MyButton1.swift @@ -0,0 +1,34 @@ +// +// MyButton1.swift +// MobileToken +// +// Created by hamed akhlaghi on 8/13/1397 AP. +// Copyright © 1397 ba24.ir. All rights reserved. +// + +import Foundation +import UIKit + +@IBDesignable + +class MyButton1: MyButton { + + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) +// setup1() + } + + func setup1() { + // Add our border here and every custom setup + super.view.layer.borderWidth = 5 + super.view.layer.cornerRadius = 5 + super.view.layer.borderColor = UIColor.green.cgColor + super.view.layer.backgroundColor = UIColor.gray.cgColor + super.view.titleLabel!.font = UIFont.systemFont(ofSize: 20) + + } + + +} + diff --git a/MobileToken/MyButton1.xib b/MobileToken/MyButton1.xib new file mode 100644 index 0000000..98a6c13 --- /dev/null +++ b/MobileToken/MyButton1.xib @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/MobileToken/assets/Assets.xcassets/CustomColor.colorset/Contents.json b/MobileToken/assets/Assets.xcassets/CustomColor.colorset/Contents.json new file mode 100644 index 0000000..c6e5d3d --- /dev/null +++ b/MobileToken/assets/Assets.xcassets/CustomColor.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "1.000", + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000" + } + } + } + ] +} \ No newline at end of file diff --git a/MobileToken/ui/viewcontroller/ViewController.swift b/MobileToken/ui/viewcontroller/ViewController.swift index 01505bc..21d96d5 100644 --- a/MobileToken/ui/viewcontroller/ViewController.swift +++ b/MobileToken/ui/viewcontroller/ViewController.swift @@ -11,6 +11,8 @@ import ObjectMapper import RealmSwift class ViewController: UIViewController { + @IBOutlet weak var bt: MyButton! + @IBOutlet weak var bt1: MyButton1! @IBOutlet weak var progressView: UIProgressView! @IBOutlet var width: NSLayoutConstraint! @IBOutlet weak var lbOtp: UILabel! @@ -19,11 +21,13 @@ class ViewController: UIViewController { var frame: CGRect? override func viewDidLoad() { super.viewDidLoad() - + bt1.setTitle("Salam", for: .normal) progressView.progress = 0 progressView.trackTintColor = .white progressView.progressTintColor = .red self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(ViewController.updateTimer), userInfo: nil, repeats: true) + UILabel.appearance().font = UIFont(name: "IranSansRegular", size: UILabel.appearance().font.pointSize) + } @objc func updateTimer() { @@ -39,6 +43,10 @@ class ViewController: UIViewController { start(self) self.lbOtp.text = "12345 رمز یکبار مصرف" + let font = UIFont(name: "IranSansRegular.ttf", size: 85) + bt1.setTitle("رمز یکبار مصرف", for: .normal) + bt.titleLabel?.text = "رمز یکبار مصرف" + bt.titleLabel?.font = font } diff --git a/MobileToken/view/basic/Base.lproj/Main.storyboard b/MobileToken/view/basic/Base.lproj/Main.storyboard index 732c453..9dabe6b 100644 --- a/MobileToken/view/basic/Base.lproj/Main.storyboard +++ b/MobileToken/view/basic/Base.lproj/Main.storyboard @@ -45,6 +45,7 @@ + @@ -66,9 +79,12 @@ + + + @@ -80,6 +96,7 @@ + @@ -88,6 +105,8 @@ + + diff --git a/MobileToken/view/nibs/CardCell.xib b/MobileToken/view/nibs/CardCell.xib index d4cae86..04cd775 100644 --- a/MobileToken/view/nibs/CardCell.xib +++ b/MobileToken/view/nibs/CardCell.xib @@ -43,8 +43,8 @@