Skip to content

Commit da6e704

Browse files
committed
#3 add Background color for the filled textField
1 parent 7f63ed5 commit da6e704

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

DPOTPView/DPOTPView.xcodeproj/project.pbxproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
isa = PBXProject;
187187
attributes = {
188188
LastSwiftUpdateCheck = 1120;
189-
LastUpgradeCheck = 1120;
189+
LastUpgradeCheck = 1140;
190190
ORGANIZATIONNAME = datt;
191191
TargetAttributes = {
192192
C6604BEA247B2037005F402D = {
@@ -289,7 +289,7 @@
289289
C6604BF5247B2037005F402D /* Debug */ = {
290290
isa = XCBuildConfiguration;
291291
buildSettings = {
292-
CODE_SIGN_IDENTITY = "iPhone Developer";
292+
CODE_SIGN_IDENTITY = "";
293293
CODE_SIGN_STYLE = Manual;
294294
CURRENT_PROJECT_VERSION = 1;
295295
DEFINES_MODULE = YES;
@@ -321,7 +321,7 @@
321321
C6604BF6247B2037005F402D /* Release */ = {
322322
isa = XCBuildConfiguration;
323323
buildSettings = {
324-
CODE_SIGN_IDENTITY = "iPhone Developer";
324+
CODE_SIGN_IDENTITY = "";
325325
CODE_SIGN_STYLE = Manual;
326326
CURRENT_PROJECT_VERSION = 1;
327327
DEFINES_MODULE = YES;
@@ -471,13 +471,14 @@
471471
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
472472
CODE_SIGN_IDENTITY = "iPhone Developer";
473473
CODE_SIGN_STYLE = Manual;
474-
DEVELOPMENT_TEAM = 3Y587YMRM5;
474+
DEVELOPMENT_TEAM = "";
475475
INFOPLIST_FILE = DPOTPView/Info.plist;
476476
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
477477
LD_RUNPATH_SEARCH_PATHS = (
478478
"$(inherited)",
479479
"@executable_path/Frameworks",
480480
);
481+
MARKETING_VERSION = 1;
481482
PRODUCT_BUNDLE_IDENTIFIER = "com.datt.DPOTPView-example";
482483
PRODUCT_NAME = "$(TARGET_NAME)";
483484
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -493,13 +494,14 @@
493494
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
494495
CODE_SIGN_IDENTITY = "iPhone Developer";
495496
CODE_SIGN_STYLE = Manual;
496-
DEVELOPMENT_TEAM = 3Y587YMRM5;
497+
DEVELOPMENT_TEAM = "";
497498
INFOPLIST_FILE = DPOTPView/Info.plist;
498499
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
499500
LD_RUNPATH_SEARCH_PATHS = (
500501
"$(inherited)",
501502
"@executable_path/Frameworks",
502503
);
504+
MARKETING_VERSION = 1;
503505
PRODUCT_BUNDLE_IDENTIFIER = "com.datt.DPOTPView-example";
504506
PRODUCT_NAME = "$(TARGET_NAME)";
505507
PROVISIONING_PROFILE_SPECIFIER = "";

DPOTPView/DPOTPView/Base.lproj/Main.storyboard

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
<userDefinedRuntimeAttribute type="color" keyPath="backGroundColorTextField">
9191
<color key="value" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
9292
</userDefinedRuntimeAttribute>
93+
<userDefinedRuntimeAttribute type="color" keyPath="backGroundColorFilledTextField">
94+
<color key="value" red="0.50196078430000002" green="0.14117647059999999" blue="0.59999999999999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
95+
</userDefinedRuntimeAttribute>
9396
</userDefinedRuntimeAttributes>
9497
</view>
9598
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XWD-DZ-vzi" customClass="DPOTPView" customModule="DPOTPView_Example" customModuleProvider="target">

DPOTPView/DPOTPView/DPOTPView/DPOTPView.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public protocol DPOTPViewDelegate {
4545
/** Background color for the textField */
4646
@IBInspectable open dynamic var backGroundColorTextField: UIColor = UIColor.clear
4747

48+
/** Background color for the filled textField */
49+
@IBInspectable open dynamic var backGroundColorFilledTextField: UIColor?
50+
4851
/** Border color for the TextField */
4952
@IBInspectable open dynamic var borderColorTextField: UIColor?
5053

@@ -146,7 +149,7 @@ public protocol DPOTPViewDelegate {
146149
textField.borderStyle = .none
147150
textField.tag = i * 1000
148151
textField.tintColor = tintColorTextField
149-
textField.layer.backgroundColor = backGroundColorTextField.cgColor
152+
textField.backgroundColor = backGroundColorTextField
150153
textField.isSecureTextEntry = isSecureTextEntry
151154
textField.font = fontTextField
152155
textField.keyboardAppearance = isDarkKeyboard ? .dark : .default
@@ -285,10 +288,19 @@ protocol OTPBackTextFieldDelegate {
285288
}
286289

287290

288-
class OTPBackTextField: UITextField {
291+
fileprivate class OTPBackTextField: UITextField {
289292

290293
var OTPBackDelegate : OTPBackTextFieldDelegate?
291294
weak var dpOTPView : DPOTPView!
295+
override var text: String? {
296+
didSet {
297+
if text?.isEmpty ?? true {
298+
self.backgroundColor = dpOTPView.backGroundColorTextField
299+
} else {
300+
self.backgroundColor = dpOTPView.backGroundColorFilledTextField ?? dpOTPView.backGroundColorTextField
301+
}
302+
}
303+
}
292304

293305
override func deleteBackward() {
294306
super.deleteBackward()
@@ -383,7 +395,7 @@ class OTPBackTextField: UITextField {
383395
}
384396

385397

386-
extension String {
398+
fileprivate extension String {
387399
subscript(_ i: Int) -> String {
388400
let idx1 = index(startIndex, offsetBy: i)
389401
let idx2 = index(idx1, offsetBy: 1)

0 commit comments

Comments
 (0)