Skip to content

Commit 4cde4f5

Browse files
author
Aman
committed
Initial code include UIButtonExteniosn, UIView Extension, UITextViewExtension, UITextFieldExtension, UILabelExtension, UICollectionVIewCellExtension, UITabelViewExtension, UIImageExtension and String
1 parent 93d0b32 commit 4cde4f5

File tree

76 files changed

+3949
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3949
-7
lines changed

AGCommonCodeSwift.podspec

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# Be sure to run `pod lib lint AGCommonCodeSwift.podspec' to ensure this is a
3+
# valid spec before submitting.
4+
#
5+
# Any lines starting with a # are optional, but their use is encouraged
6+
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
7+
#
8+
9+
Pod::Spec.new do |s|
10+
s.name = 'AGCommonCodeSwift'
11+
s.version = '0.1.0'
12+
s.summary = 'AGCommonCodeSwift Is used for swift UIKit extension for use by storyboard or save time.'
13+
14+
# This description is used to generate tags and improve search results.
15+
# * Think: What does it do? Why did you write it? What is the focus?
16+
# * Try to keep it short, snappy and to the point.
17+
# * Write the description between the DESC delimiters below.
18+
# * Finally, don't worry about the indent, CocoaPods strips it!
19+
20+
s.description = <<-DESC
21+
TODO: In this pod have diffrent types of extensions like UIButtonExteniosn, UIView Extension, UITextViewExtension, UITextFieldExtension, UILabelExtension, UICollectionVIewCellExtension, UITabelViewExtension, UIImageExtension and String Extension. In these extensions we have diffrent type of Functionality like corner radius, border width etc. and I will update this pod in future according to requirement.
22+
DESC
23+
24+
s.homepage = 'https://github.com/DeveloperFly/AGCommonCodeSwift'
25+
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
26+
s.license = { :type => 'MIT', :file => 'LICENSE' }
27+
s.author = { 'Aman Gupta' => '[email protected]' }
28+
s.source = { :git => 'https://github.com/DeveloperFly/AGCommonCodeSwift.git', :tag => s.version.to_s }
29+
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
30+
31+
s.ios.deployment_target = '8.0'
32+
33+
s.source_files = 'AGCommonCodeSwift/Classes/**/*'
34+
35+
# s.resource_bundles = {
36+
# 'AGCommonCodeSwift' => ['AGCommonCodeSwift/Assets/*.png']
37+
# }
38+
39+
# s.public_header_files = 'Pod/Classes/**/*.h'
40+
# s.frameworks = 'UIKit', 'MapKit'
41+
# s.dependency 'AFNetworking', '~> 2.3'
42+
end

AGCommonCodeSwift/Assets/.gitkeep

Whitespace-only changes.

AGCommonCodeSwift/Classes/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// AGNSMutableAttributedStringExtended.swift
3+
// AGCommonCodeSwift
4+
//
5+
// Created by Aman Gupta on 26/12/17.
6+
//
7+
8+
import Foundation
9+
import UIKit
10+
11+
//public extension NSMutableAttributedString {
12+
//// func bold(_ text: String, font: UIFont) -> NSMutableAttributedString {
13+
//// let attribute:[NSAttributedStringKey : Any] = [.font : font]
14+
//// let boldString = NSMutableAttributedString(string: "\(text)", attributes: attribute)
15+
//// self.append(boldString)
16+
//// return self
17+
//// }
18+
//
19+
// public func normal(_ text:String)->NSMutableAttributedString {
20+
// let normal = NSAttributedString(string: text)
21+
// self.append(normal)
22+
// return self
23+
// }
24+
//
25+
//}
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
//
2+
// AGStringExtended.swift
3+
// AGCommonCodeSwift
4+
//
5+
// Created by Aman Gupta on 26/12/17.
6+
//
7+
8+
import UIKit
9+
10+
public extension String {
11+
// MARK: - Public variables
12+
public var first: String {
13+
return String(prefix(1))
14+
}
15+
16+
public var last: String {
17+
return String(suffix(1))
18+
}
19+
20+
public var uppercaseFirstChar: String {
21+
return first.uppercased() + String(dropFirst())
22+
}
23+
24+
public var vowels: [String] {
25+
get {
26+
return ["a", "e", "i", "o", "u"]
27+
}
28+
}
29+
30+
public var consonants: [String] {
31+
get {
32+
return ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "z"]
33+
}
34+
}
35+
36+
public var length: Int {
37+
get {
38+
return self.stringByTrimmingWhiteSpaceAndNewLine().count
39+
}
40+
}
41+
42+
//To check whether email is valid or not
43+
public func isEmail() -> Bool {
44+
if self.isEmptyString() {
45+
return false
46+
}
47+
let emailRegex = "[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}" as String
48+
let emailText = NSPredicate(format: "SELF MATCHES %@",emailRegex)
49+
let isValid = emailText.evaluate(with: self) as Bool
50+
return isValid
51+
}
52+
53+
//To check whether URL is valid
54+
public func isURL() -> Bool {
55+
let urlRegex = "(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+" as String
56+
let urlText = NSPredicate(format: "SELF MATCHES %@", urlRegex)
57+
let isValid = urlText.evaluate(with: self) as Bool
58+
return isValid
59+
}
60+
61+
//To check whether image URL is valid
62+
public func isImageURL() -> Bool {
63+
if self.isURL() {
64+
if self.range(of: ".png") != nil || self.range(of: ".jpg") != nil || self.range(of: ".jpeg") != nil {
65+
return true
66+
} else {
67+
return false
68+
}
69+
} else {
70+
return false
71+
}
72+
}
73+
74+
//To check whether string is empty
75+
public func isEmptyString() -> Bool {
76+
return self.stringByTrimmingWhiteSpace().count == 0 ? true : false
77+
}
78+
79+
//Get string by removing white space
80+
public func stringByTrimmingWhiteSpace() -> String {
81+
return self.trimmingCharacters(in: .whitespaces)
82+
}
83+
84+
//Get string by removing white space & new line
85+
public func stringByTrimmingWhiteSpaceAndNewLine() -> String {
86+
return self.trimmingCharacters(in: .whitespacesAndNewlines)
87+
}
88+
89+
//Remove substring in string
90+
mutating public func removeSubString(subString: String) -> String {
91+
if self.contains(subString) {
92+
guard let stringRange = self.range(of: subString) else { return self }
93+
return self.replacingCharacters(in: stringRange, with: "")
94+
}
95+
return self
96+
}
97+
98+
public static func getString(message: Any?) -> String {
99+
guard let strMessage = message as? String else {
100+
guard let doubleValue = message as? Double else {
101+
guard let intValue = message as? Int else {
102+
guard let int64Value = message as? Int64 else {
103+
return ""
104+
}
105+
return String(int64Value)
106+
}
107+
return String(intValue)
108+
}
109+
110+
let formatter = NumberFormatter()
111+
formatter.minimumFractionDigits = 0
112+
formatter.maximumFractionDigits = 2
113+
formatter.minimumIntegerDigits = 1
114+
guard let formattedNumber = formatter.string(from: NSNumber(value: doubleValue)) else {
115+
return ""
116+
}
117+
return formattedNumber
118+
}
119+
return strMessage.stringByTrimmingWhiteSpaceAndNewLine()
120+
}
121+
122+
public func replace(target: String, withString: String) -> String {
123+
return self.replacingOccurrences(of: target, with: withString)
124+
}
125+
126+
//Get character array by string
127+
public func getArrayByString() -> [Character] {
128+
return Array(self)
129+
}
130+
131+
}
132+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// AGUIButtonBorder.swift
3+
// AGCommonCodeSwift
4+
//
5+
// Created by Aman Gupta on 21/12/17.
6+
//
7+
8+
import UIKit
9+
@IBDesignable
10+
11+
open class AGUIButtonBorder: AGUIButtonShadowBorder {
12+
// MARK: - Border width
13+
@IBInspectable open var borderWidth: CGFloat = 0 {
14+
didSet {
15+
layer.borderWidth = borderWidth
16+
}
17+
}
18+
19+
// MARK: - Border color
20+
@IBInspectable open var borderColor: UIColor? {
21+
didSet {
22+
layer.borderColor = borderColor?.cgColor
23+
}
24+
}
25+
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// AGUIButtonClassExtension.swift
3+
// AGCommonCodeSwift
4+
//
5+
// Created by Aman Gupta on 21/12/17.
6+
//
7+
8+
import UIKit
9+
@IBDesignable
10+
11+
open class AGUIButtonClassExtension: AGUIButtonSublayer {
12+
13+
/*
14+
// Only override draw() if you perform custom drawing.
15+
// An empty implementation adversely affects performance during animation.
16+
override func draw(_ rect: CGRect) {
17+
// Drawing code
18+
}
19+
*/
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// AGUIButtonCornerRadius.swift
3+
// AGCommonCodeSwift
4+
//
5+
// Created by Aman Gupta on 21/12/17.
6+
//
7+
8+
import UIKit
9+
@IBDesignable
10+
11+
open class AGUIButtonCornerRadius: AGUIButtonBorder {
12+
// MARK: - Corner radius
13+
@IBInspectable open var cornerRadius: CGFloat = 0 {
14+
didSet {
15+
layer.cornerRadius = cornerRadius
16+
layer.masksToBounds = cornerRadius > 0
17+
}
18+
}
19+
20+
//MARK : - Button make circle
21+
@IBInspectable open var makeCircle: Bool = false {
22+
didSet {
23+
layer.masksToBounds = cornerRadius > 0
24+
}
25+
}
26+
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// AGUIButtonCustomFont.swift
3+
// AGCommonCodeSwift
4+
//
5+
// Created by Aman Gupta on 21/12/17.
6+
//
7+
8+
import UIKit
9+
@IBDesignable
10+
11+
open class AGUIButtonCustomFont: UIButton {
12+
@IBInspectable open var fontSize: CGFloat = 18 {
13+
didSet {
14+
}
15+
}
16+
17+
@IBInspectable open var fontTypeInterger: Int = 0 {
18+
didSet {
19+
}
20+
}
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// AGUIButtonShadowBorder.swift
3+
// AGCommonCodeSwift
4+
//
5+
// Created by Aman Gupta on 21/12/17.
6+
//
7+
8+
import UIKit
9+
@IBDesignable
10+
11+
open class AGUIButtonShadowBorder: AGUIButtonCustomFont {
12+
// MARK: - Shadow radius variables
13+
@IBInspectable open var shadowRadius: CGFloat = 0 {
14+
didSet {
15+
layer.shadowOffset = CGSize.init(width: 0.1, height: 0.1)
16+
layer.shadowRadius = shadowRadius
17+
layer.shadowOpacity = 1.0
18+
}
19+
}
20+
21+
@IBInspectable open var masksToBounds: Bool = false {
22+
didSet {
23+
layer.masksToBounds = masksToBounds
24+
}
25+
}
26+
27+
@IBInspectable open var shodowColor: UIColor? {
28+
didSet {
29+
layer.shadowColor = shodowColor?.cgColor
30+
}
31+
}
32+
33+
}

0 commit comments

Comments
 (0)