Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
dcac2ce7
Commit
dcac2ce7
authored
Jan 29, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 单行选择器
parent
2f3cc4ef
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
483 additions
and
0 deletions
+483
-0
project.pbxproj
galaxy/galaxy.xcodeproj/project.pbxproj
+12
-0
YHFamilyMemberFormVC.swift
...viceProcess(流程)/FamilyMember/C/YHFamilyMemberFormVC.swift
+6
-0
YHFormPickerView.swift
...s(流程)/FamilyMember/View/PickerView/YHFormPickerView.swift
+465
-0
No files found.
galaxy/galaxy.xcodeproj/project.pbxproj
View file @
dcac2ce7
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
042FBBC72B64CFBF00F9DE23
/* YHChildInitialInfoVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
042FBBC62B64CFBF00F9DE23
/* YHChildInitialInfoVC.swift */
;
};
042FBBC72B64CFBF00F9DE23
/* YHChildInitialInfoVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
042FBBC62B64CFBF00F9DE23
/* YHChildInitialInfoVC.swift */
;
};
042FBBC92B64DC8900F9DE23
/* YHFormItemExpireDateCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
042FBBC82B64DC8900F9DE23
/* YHFormItemExpireDateCell.swift */
;
};
042FBBC92B64DC8900F9DE23
/* YHFormItemExpireDateCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
042FBBC82B64DC8900F9DE23
/* YHFormItemExpireDateCell.swift */
;
};
042FBBCB2B65058000F9DE23
/* YHChildBasicInfoVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
042FBBCA2B65058000F9DE23
/* YHChildBasicInfoVC.swift */
;
};
042FBBCB2B65058000F9DE23
/* YHChildBasicInfoVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
042FBBCA2B65058000F9DE23
/* YHChildBasicInfoVC.swift */
;
};
042FBBD12B673CEF00F9DE23
/* YHFormPickerView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
042FBBD02B673CEF00F9DE23
/* YHFormPickerView.swift */
;
};
0468D4202B49320900CFB916
/* YHVerificationCodeLoginController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D41F2B49320900CFB916
/* YHVerificationCodeLoginController.swift */
;
};
0468D4202B49320900CFB916
/* YHVerificationCodeLoginController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D41F2B49320900CFB916
/* YHVerificationCodeLoginController.swift */
;
};
0468D4222B493A5E00CFB916
/* YHPhoneMessageView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D4212B493A5E00CFB916
/* YHPhoneMessageView.swift */
;
};
0468D4222B493A5E00CFB916
/* YHPhoneMessageView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D4212B493A5E00CFB916
/* YHPhoneMessageView.swift */
;
};
0468D4242B494BEA00CFB916
/* YHCodeResultViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D4232B494BEA00CFB916
/* YHCodeResultViewController.swift */
;
};
0468D4242B494BEA00CFB916
/* YHCodeResultViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D4232B494BEA00CFB916
/* YHCodeResultViewController.swift */
;
};
...
@@ -203,6 +204,7 @@
...
@@ -203,6 +204,7 @@
042FBBC62B64CFBF00F9DE23
/* YHChildInitialInfoVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHChildInitialInfoVC.swift
;
sourceTree
=
"<group>"
;
};
042FBBC62B64CFBF00F9DE23
/* YHChildInitialInfoVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHChildInitialInfoVC.swift
;
sourceTree
=
"<group>"
;
};
042FBBC82B64DC8900F9DE23
/* YHFormItemExpireDateCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHFormItemExpireDateCell.swift
;
sourceTree
=
"<group>"
;
};
042FBBC82B64DC8900F9DE23
/* YHFormItemExpireDateCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHFormItemExpireDateCell.swift
;
sourceTree
=
"<group>"
;
};
042FBBCA2B65058000F9DE23
/* YHChildBasicInfoVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHChildBasicInfoVC.swift
;
sourceTree
=
"<group>"
;
};
042FBBCA2B65058000F9DE23
/* YHChildBasicInfoVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHChildBasicInfoVC.swift
;
sourceTree
=
"<group>"
;
};
042FBBD02B673CEF00F9DE23
/* YHFormPickerView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHFormPickerView.swift
;
sourceTree
=
"<group>"
;
};
0468D41F2B49320900CFB916
/* YHVerificationCodeLoginController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHVerificationCodeLoginController.swift
;
sourceTree
=
"<group>"
;
};
0468D41F2B49320900CFB916
/* YHVerificationCodeLoginController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHVerificationCodeLoginController.swift
;
sourceTree
=
"<group>"
;
};
0468D4212B493A5E00CFB916
/* YHPhoneMessageView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHPhoneMessageView.swift
;
sourceTree
=
"<group>"
;
};
0468D4212B493A5E00CFB916
/* YHPhoneMessageView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHPhoneMessageView.swift
;
sourceTree
=
"<group>"
;
};
0468D4232B494BEA00CFB916
/* YHCodeResultViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHCodeResultViewController.swift
;
sourceTree
=
"<group>"
;
};
0468D4232B494BEA00CFB916
/* YHCodeResultViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHCodeResultViewController.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -382,6 +384,7 @@
...
@@ -382,6 +384,7 @@
041B52892B5E14EB007EBCEB
/* View */
=
{
041B52892B5E14EB007EBCEB
/* View */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
042FBBCF2B673CCF00F9DE23
/* PickerView */
,
041B52922B5E6CBA007EBCEB
/* YHFormItemTitleCell.swift */
,
041B52922B5E6CBA007EBCEB
/* YHFormItemTitleCell.swift */
,
041B52942B5E7037007EBCEB
/* YHFormItemAddCell.swift */
,
041B52942B5E7037007EBCEB
/* YHFormItemAddCell.swift */
,
041B528A2B5E15F1007EBCEB
/* YHFormItemQuestionCell.swift */
,
041B528A2B5E15F1007EBCEB
/* YHFormItemQuestionCell.swift */
,
...
@@ -420,6 +423,14 @@
...
@@ -420,6 +423,14 @@
path
=
M
;
path
=
M
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
042FBBCF2B673CCF00F9DE23
/* PickerView */
=
{
isa
=
PBXGroup
;
children
=
(
042FBBD02B673CEF00F9DE23
/* YHFormPickerView.swift */
,
);
path
=
PickerView
;
sourceTree
=
"<group>"
;
};
0468D4292B55017400CFB916
/* Analytics */
=
{
0468D4292B55017400CFB916
/* Analytics */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
@@ -1137,6 +1148,7 @@
...
@@ -1137,6 +1148,7 @@
A5ACE9332B4564F7002C94D2
/* NetBaseModel.swift in Sources */
,
A5ACE9332B4564F7002C94D2
/* NetBaseModel.swift in Sources */
,
049A48AA2B49536000D0C641
/* YHAboutUsAdvantageCell.swift in Sources */
,
049A48AA2B49536000D0C641
/* YHAboutUsAdvantageCell.swift in Sources */
,
A5C5B3002B55623800A7C5D1
/* ContentBaseViewController.swift in Sources */
,
A5C5B3002B55623800A7C5D1
/* ContentBaseViewController.swift in Sources */
,
042FBBD12B673CEF00F9DE23
/* YHFormPickerView.swift in Sources */
,
A5573ED22B317BFF00D98EC0
/* AppDelegate.swift in Sources */
,
A5573ED22B317BFF00D98EC0
/* AppDelegate.swift in Sources */
,
A5ACE9542B4564F7002C94D2
/* YHNavigationController.swift in Sources */
,
A5ACE9542B4564F7002C94D2
/* YHNavigationController.swift in Sources */
,
A5FD63DF2B6639AD00D1D9DA
/* YHScoreDataModel.swift in Sources */
,
A5FD63DF2B6639AD00D1D9DA
/* YHScoreDataModel.swift in Sources */
,
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/ServiceProcess(流程)/FamilyMember/C/YHFamilyMemberFormVC.swift
View file @
dcac2ce7
...
@@ -628,6 +628,12 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
...
@@ -628,6 +628,12 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
let
picker
=
YHFormPickerView
(
type
:
.
marriage
)
picker
.
selectTitle
=
"女"
picker
.
selectType
=
.
marriage
(
.
separated
)
picker
.
show
()
return
let
arr
=
items
[
indexPath
.
section
]
let
arr
=
items
[
indexPath
.
section
]
let
item
:
YHFormItemProtocol
=
arr
[
indexPath
.
row
]
let
item
:
YHFormItemProtocol
=
arr
[
indexPath
.
row
]
...
...
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/ServiceProcess(流程)/FamilyMember/View/PickerView/YHFormPickerView.swift
0 → 100644
View file @
dcac2ce7
//
// YHFormPickerView.swift
// galaxy
//
// Created by edy on 2024/1/29.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
enum
YHFormPickerViewType
:
Int
{
// 按自然顺序递增
case
none
=
0
case
degree
=
1
case
marriage
=
2
case
edution
=
3
case
occupation
=
4
case
gender
=
5
}
enum
YHFormPickerViewSubType
{
case
none
case
marriage
(
YHPickerViewMarriageType
)
case
degree
(
YHPickerViewDegreeType
)
case
education
(
YHPickerViewEducationType
)
case
occupation
(
YHPickerViewOccupationType
)
case
gender
(
YHPickerViewGenderType
)
var
title
:
String
{
switch
self
{
case
.
none
:
return
""
.
local
case
.
marriage
(
.
unmarriage
):
return
"未婚"
.
local
case
.
marriage
(
.
marriaged
):
return
"已婚"
.
local
case
.
marriage
(
.
separated
):
return
"分居"
.
local
case
.
marriage
(
.
divorced
):
return
"离婚"
.
local
case
.
marriage
(
.
widowed
):
return
"丧偶"
.
local
case
.
degree
(
.
bachelor
):
return
"学士学位"
.
local
case
.
degree
(
.
master
):
return
"硕士学位"
.
local
case
.
degree
(
.
doctor
):
return
"博士学位"
.
local
case
.
education
(
.
fullTime
):
return
"全日制"
.
local
case
.
education
(
.
partTime
):
return
"兼职制"
.
local
case
.
education
(
.
distanceCourses
):
return
"遥距课程"
.
local
case
.
occupation
(
.
onTheJob
):
return
"在职"
.
local
case
.
occupation
(
.
retire
):
return
"退休"
.
local
case
.
occupation
(
.
unemployed
):
return
"无业"
.
local
case
.
occupation
(
.
student
):
return
"学生"
.
local
case
.
gender
(
.
male
):
return
"男"
.
local
case
.
gender
(
.
female
):
return
"女"
.
local
}
}
static
func
getType
(
_
title
:
String
?)
->
YHFormPickerViewSubType
{
guard
let
title
=
title
else
{
return
.
none
}
if
title
==
"未婚"
.
local
{
return
.
marriage
(
.
unmarriage
)
}
else
if
title
==
"已婚"
.
local
{
return
.
marriage
(
.
marriaged
)
}
else
if
title
==
"分居"
.
local
{
return
.
marriage
(
.
separated
)
}
else
if
title
==
"离婚"
.
local
{
return
.
marriage
(
.
divorced
)
}
else
if
title
==
"丧偶"
.
local
{
return
.
marriage
(
.
widowed
)
}
else
if
title
==
"学士学位"
.
local
{
return
.
degree
(
.
bachelor
)
}
else
if
title
==
"硕士学位"
.
local
{
return
.
degree
(
.
master
)
}
else
if
title
==
"硕士学位"
.
local
{
return
.
degree
(
.
doctor
)
}
else
if
title
==
"全日制"
.
local
{
return
.
education
(
.
fullTime
)
}
else
if
title
==
"兼读制"
.
local
{
return
.
education
(
.
partTime
)
}
else
if
title
==
"遥距课程"
.
local
{
return
.
education
(
.
distanceCourses
)
}
else
if
title
==
"在职"
.
local
{
return
.
occupation
(
.
onTheJob
)
}
else
if
title
==
"退休"
.
local
{
return
.
occupation
(
.
retire
)
}
else
if
title
==
"无业"
.
local
{
return
.
occupation
(
.
unemployed
)
}
else
if
title
==
"学生"
.
local
{
return
.
occupation
(
.
student
)
}
else
if
title
==
"男"
.
local
{
return
.
gender
(
.
male
)
}
else
if
title
==
"女"
.
local
{
return
.
gender
(
.
female
)
}
return
.
none
}
}
enum
YHPickerViewMarriageType
{
// 未婚
case
unmarriage
// 已婚
case
marriaged
// 离婚
case
divorced
// 分居
case
separated
// 丧偶
case
widowed
}
enum
YHPickerViewDegreeType
{
// 学士
case
bachelor
// 硕士
case
master
// 博士
case
doctor
}
enum
YHPickerViewEducationType
{
// 全日制
case
fullTime
// 兼读制
case
partTime
// 遥距课程
case
distanceCourses
}
enum
YHPickerViewOccupationType
{
// 在职
case
onTheJob
// 退休
case
retire
// 无业
case
unemployed
// 学生
case
student
}
enum
YHPickerViewGenderType
{
// 男
case
male
// 女
case
female
}
class
YHFormPickerViewItem
{
let
type
:
YHFormPickerViewSubType
lazy
var
title
=
{
return
type
.
title
}()
init
(
type
:
YHFormPickerViewSubType
)
{
self
.
type
=
type
}
}
class
YHFormPickerView
:
UIView
{
let
type
:
YHFormPickerViewType
var
selectType
:
YHFormPickerViewSubType
?
var
selectTitle
:
String
?
{
didSet
{
let
type
:
YHFormPickerViewSubType
=
YHFormPickerViewSubType
.
getType
(
selectTitle
)
selectType
=
type
}
}
var
selectBlock
:((
YHFormPickerViewSubType
)
->
Void
)?
var
title
:
String
?
{
didSet
{
titleLabel
.
text
=
title
}
}
lazy
var
pickerView
:
UIPickerView
=
{
let
view
=
UIPickerView
()
view
.
dataSource
=
self
view
.
delegate
=
self
return
view
}()
lazy
var
blackMaskView
:
UIView
=
{
let
view
=
UIView
()
view
.
backgroundColor
=
UIColor
(
hex
:
0x0F1214
,
alpha
:
0.5
)
let
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
dismiss
)
)
view
.
addGestureRecognizer
(
tap
)
return
view
}()
lazy
var
whiteContentView
:
UIView
=
{
let
view
=
UIView
()
view
.
backgroundColor
=
.
white
return
view
}()
lazy
var
topView
:
UIView
=
{
let
view
=
UIView
()
view
.
addSubview
(
titleLabel
)
view
.
addSubview
(
cancelBtn
)
view
.
addSubview
(
confirmBtn
)
titleLabel
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalToSuperview
()
}
cancelBtn
.
snp
.
makeConstraints
{
make
in
make
.
left
.
top
.
bottom
.
equalToSuperview
()
make
.
width
.
equalTo
(
60
)
}
confirmBtn
.
snp
.
makeConstraints
{
make
in
make
.
right
.
top
.
bottom
.
equalToSuperview
()
make
.
width
.
equalTo
(
60
)
}
return
view
}()
lazy
var
titleLabel
:
UILabel
=
{
let
label
=
UILabel
()
label
.
textColor
=
UIColor
(
hexString
:
"#222222"
)
label
.
textAlignment
=
.
center
label
.
font
=
UIFont
.
PingFangScR
(
ofSize
:
16
)
label
.
text
=
"请选择"
return
label
}()
lazy
var
cancelBtn
:
UIButton
=
{
let
btn
=
UIButton
()
btn
.
setTitle
(
"取消"
.
local
,
for
:
.
normal
)
btn
.
titleLabel
?
.
font
=
UIFont
.
PingFangScR
(
ofSize
:
14
)
btn
.
setTitleColor
(
UIColor
(
hex
:
0x222222
),
for
:
.
normal
)
btn
.
addTarget
(
self
,
action
:
#selector(
didClickCancelButton
)
,
for
:
.
touchUpInside
)
return
btn
}()
lazy
var
confirmBtn
:
UIButton
=
{
let
btn
=
UIButton
()
btn
.
setTitle
(
"确定"
.
local
,
for
:
.
normal
)
btn
.
titleLabel
?
.
font
=
UIFont
.
PingFangScR
(
ofSize
:
14
)
btn
.
setTitleColor
(
UIColor
(
hex
:
0x4487F9
),
for
:
.
normal
)
btn
.
addTarget
(
self
,
action
:
#selector(
didClickConfirmButton
)
,
for
:
.
touchUpInside
)
return
btn
}()
lazy
var
dataDict
:[
YHFormPickerViewType
:
[
YHFormPickerViewItem
]]
=
{
return
[
// 此处顺序需遵循 YHFormPickerViewType 枚举顺序
// 默认无
.
none
:[],
// 学位
.
degree
:
[
YHFormPickerViewItem
(
type
:
.
degree
(
.
bachelor
)),
YHFormPickerViewItem
(
type
:
.
degree
(
.
master
)),
YHFormPickerViewItem
(
type
:
.
degree
(
.
doctor
))],
// 婚姻
.
marriage
:
[
YHFormPickerViewItem
(
type
:
.
marriage
(
.
unmarriage
)),
YHFormPickerViewItem
(
type
:
.
marriage
(
.
marriaged
)),
YHFormPickerViewItem
(
type
:
.
marriage
(
.
divorced
)),
YHFormPickerViewItem
(
type
:
.
marriage
(
.
separated
)),
YHFormPickerViewItem
(
type
:
.
marriage
(
.
widowed
))],
// 教育
.
edution
:
[
YHFormPickerViewItem
(
type
:
.
education
(
.
fullTime
)),
YHFormPickerViewItem
(
type
:
.
education
(
.
partTime
)),
YHFormPickerViewItem
(
type
:
.
education
(
.
distanceCourses
))],
// 职业
.
occupation
:
[
YHFormPickerViewItem
(
type
:
.
occupation
(
.
onTheJob
)),
YHFormPickerViewItem
(
type
:
.
occupation
(
.
retire
)),
YHFormPickerViewItem
(
type
:
.
occupation
(
.
unemployed
)),
YHFormPickerViewItem
(
type
:
.
occupation
(
.
student
))],
// 性别
.
gender
:
[
YHFormPickerViewItem
(
type
:
.
gender
(
.
male
)),
YHFormPickerViewItem
(
type
:
.
gender
(
.
female
))],
]
}()
init
(
type
:
YHFormPickerViewType
)
{
self
.
type
=
type
super
.
init
(
frame
:
UIScreen
.
main
.
bounds
)
self
.
createUI
()
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
func
show
()
{
showSelectType
(
&
selectType
)
UIApplication
.
shared
.
yhKeyWindow
()?
.
addSubview
(
self
)
}
@objc
func
dismiss
()
{
self
.
removeFromSuperview
()
}
func
createUI
()
{
self
.
addSubview
(
blackMaskView
)
self
.
addSubview
(
whiteContentView
)
whiteContentView
.
addSubview
(
topView
)
whiteContentView
.
addSubview
(
pickerView
)
blackMaskView
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalToSuperview
()
}
whiteContentView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
bottom
.
equalToSuperview
()
make
.
top
.
equalToSuperview
()
.
offset
(
KScreenHeight
/
3.0
)
}
topView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
top
.
equalToSuperview
()
make
.
height
.
equalTo
(
52
)
}
pickerView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
topView
.
snp
.
bottom
)
make
.
left
.
right
.
bottom
.
equalToSuperview
()
}
}
@objc
func
didClickCancelButton
()
{
dismiss
()
}
@objc
func
didClickConfirmButton
()
{
if
let
selectBlock
=
selectBlock
{
if
let
selectType
=
selectType
{
selectBlock
(
selectType
)
}
else
{
// 默认选中第一行
let
arr
=
dataDict
[
type
]
if
let
arr
=
arr
,
!
arr
.
isEmpty
{
let
item
:
YHFormPickerViewItem
=
arr
[
0
]
selectType
=
item
.
type
selectBlock
(
item
.
type
)
}
}
}
dismiss
()
}
func
showSelectType
(
_
selectType
:
inout
YHFormPickerViewSubType
?)
{
// 处理从外部传入的选中第几行的参数
// 是否找到选中行数据
var
selectIndex
:
Int
=
-
1
if
let
selectType
=
selectType
,
let
arr
=
dataDict
[
type
],
!
arr
.
isEmpty
{
for
(
index
,
item
)
in
arr
.
enumerated
()
{
if
selectType
.
title
==
item
.
type
.
title
{
selectIndex
=
index
break
}
}
}
if
selectIndex
!=
-
1
{
// 找到了选择行
pickerView
.
selectRow
(
selectIndex
,
inComponent
:
0
,
animated
:
true
)
}
else
{
// 未找到选中行数据则滚动至第一行
if
dataDict
[
type
]?
.
isEmpty
==
true
{
return
}
if
let
arr
=
dataDict
[
type
],
!
arr
.
isEmpty
{
let
item
=
arr
[
0
]
selectType
=
item
.
type
pickerView
.
selectRow
(
0
,
inComponent
:
0
,
animated
:
true
)
}
}
}
}
extension
YHFormPickerView
:
UIPickerViewDelegate
,
UIPickerViewDataSource
{
func
numberOfComponents
(
in
pickerView
:
UIPickerView
)
->
Int
{
return
1
}
func
pickerView
(
_
pickerView
:
UIPickerView
,
numberOfRowsInComponent
component
:
Int
)
->
Int
{
if
let
arr
=
dataDict
[
type
],
!
arr
.
isEmpty
{
return
arr
.
count
}
return
0
}
func
pickerView
(
_
pickerView
:
UIPickerView
,
titleForRow
row
:
Int
,
forComponent
component
:
Int
)
->
String
?
{
if
let
arr
=
dataDict
[
type
]
{
if
0
<=
row
&&
row
<
arr
.
count
{
let
item
:
YHFormPickerViewItem
=
arr
[
row
]
return
item
.
title
}
}
return
""
}
func
pickerView
(
_
pickerView
:
UIPickerView
,
didSelectRow
row
:
Int
,
inComponent
component
:
Int
)
{
if
let
arr
=
dataDict
[
type
]
{
if
0
<=
row
&&
row
<
arr
.
count
{
let
item
:
YHFormPickerViewItem
=
arr
[
row
]
print
(
item
.
title
)
selectType
=
item
.
type
}
}
}
func
pickerView
(
_
pickerView
:
UIPickerView
,
viewForRow
row
:
Int
,
forComponent
component
:
Int
,
reusing
view
:
UIView
?)
->
UIView
{
let
label
=
UILabel
()
label
.
textColor
=
UIColor
(
hexString
:
"#222222"
)
label
.
textAlignment
=
.
center
label
.
font
=
UIFont
.
PingFangScR
(
ofSize
:
14
)
label
.
text
=
""
if
let
arr
=
dataDict
[
type
]
{
if
0
<=
row
&&
row
<
arr
.
count
{
let
item
:
YHFormPickerViewItem
=
arr
[
row
]
label
.
text
=
item
.
title
}
}
// 选中背景色
if
#available(iOS 14.0, *)
,
self
.
subviews
.
count
>
1
{
pickerView
.
subviews
[
1
]
.
backgroundColor
=
UIColor
(
hex
:
0x4487F9
,
alpha
:
0.06
)
}
return
label
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment