@@ -495,145 +495,6 @@ private let makeupList = [
495495
496496// MARK: make up setting
497497extension VideoProcessMain {
498- @IBAction func onShowMakeUpAction( ) {
499- let customAlertVC = UIViewController ( )
500- customAlertVC. modalPresentationStyle = . overFullScreen
501- customAlertVC. view. backgroundColor = . clear
502-
503- let alertView = UIView ( )
504- alertView. translatesAutoresizingMaskIntoConstraints = false
505- alertView. backgroundColor = UIColor . white
506- alertView. layer. shadowColor = UIColor . black. cgColor
507- alertView. layer. shadowOpacity = 0.2
508- alertView. layer. shadowOffset = CGSize ( width: 0 , height: 2 )
509- alertView. layer. shadowRadius = 4
510-
511- customAlertVC. view. addSubview ( alertView)
512-
513- NSLayoutConstraint . activate ( [
514- alertView. centerXAnchor. constraint ( equalTo: customAlertVC. view. centerXAnchor) ,
515- alertView. centerYAnchor. constraint ( equalTo: customAlertVC. view. centerYAnchor) ,
516- alertView. widthAnchor. constraint ( equalTo: customAlertVC. view. widthAnchor, constant: - 20 ) ,
517- alertView. heightAnchor. constraint ( equalToConstant: 300 )
518- ] )
519-
520- let scrollView = UIScrollView ( )
521- scrollView. translatesAutoresizingMaskIntoConstraints = false
522- alertView. addSubview ( scrollView)
523-
524- NSLayoutConstraint . activate ( [
525- scrollView. topAnchor. constraint ( equalTo: alertView. topAnchor) ,
526- scrollView. leadingAnchor. constraint ( equalTo: alertView. leadingAnchor) ,
527- scrollView. trailingAnchor. constraint ( equalTo: alertView. trailingAnchor) ,
528- scrollView. bottomAnchor. constraint ( equalTo: alertView. bottomAnchor, constant: - 50 )
529- ] )
530-
531- let contentView = UIView ( )
532- contentView. translatesAutoresizingMaskIntoConstraints = false
533- scrollView. addSubview ( contentView)
534-
535- NSLayoutConstraint . activate ( [
536- contentView. topAnchor. constraint ( equalTo: scrollView. topAnchor) ,
537- contentView. leadingAnchor. constraint ( equalTo: scrollView. leadingAnchor) ,
538- contentView. trailingAnchor. constraint ( equalTo: scrollView. trailingAnchor) ,
539- contentView. bottomAnchor. constraint ( equalTo: scrollView. bottomAnchor) ,
540- contentView. widthAnchor. constraint ( equalTo: scrollView. widthAnchor)
541- ] )
542-
543- var lastLabel : UILabel ?
544- for i in 0 ..< makeupList. count {
545- let label = UILabel ( )
546- label. translatesAutoresizingMaskIntoConstraints = false
547- label. text = makeupList [ i] [ " name " ] as? String ?? " none "
548- label. font = UIFont . systemFont ( ofSize: 12 )
549- label. textColor = . black
550- label. tag = i + 2000
551- contentView. addSubview ( label)
552-
553- var valueView : UIView ?
554- let key = makeupList [ i] [ " key " ] as? String ?? " "
555- let type = makeupList [ i] [ " type " ] as? String ?? " "
556- if type == " slider " {
557- let value = makeupList [ i] [ " value " ] as? [ Float ] ?? [ ]
558- let sliderView = UISlider ( )
559- label. text = String ( format: " %@[%.f] " , label. text ?? " none " , sliderView. value)
560- sliderView. minimumValue = value. first ?? 0
561- sliderView. maximumValue = value. last ?? 1
562- sliderView. value = makeupParams [ key] as? Float ?? 0
563- sliderView. addTarget ( self , action: #selector( makeupSliderAction ( _: ) ) , for: . valueChanged)
564- valueView = sliderView
565- } else if type == " switch " {
566- let switchView = UISwitch ( )
567- switchView. isOn = makeupParams [ key] as? Bool ?? false
568- switchView. addTarget ( self , action: #selector( makeupSwitchAction ( _: ) ) , for: . valueChanged)
569- valueView = switchView
570- } else if type == " segment " {
571- let value = makeupList [ i] [ " value " ] as? [ String ] ?? [ ]
572- let segmentView = UISegmentedControl ( items: value)
573- segmentView. selectedSegmentIndex = makeupParams [ key] as? Int ?? 0
574- segmentView. addTarget ( self , action: #selector( makeupSegmentAction ( _: ) ) , for: . valueChanged)
575- valueView = segmentView
576- }
577- guard let valueView = valueView else { return }
578- valueView. translatesAutoresizingMaskIntoConstraints = false
579- contentView. addSubview ( valueView)
580- valueView. tag = i + 1000
581- NSLayoutConstraint . activate ( [
582- label. topAnchor. constraint ( equalTo: lastLabel? . bottomAnchor ?? contentView. topAnchor, constant: lastLabel == nil ? 10 : 10 ) ,
583- label. leadingAnchor. constraint ( equalTo: contentView. leadingAnchor, constant: 15 ) ,
584- label. trailingAnchor. constraint ( equalTo: valueView. leadingAnchor, constant: - 10 ) ,
585- label. heightAnchor. constraint ( equalToConstant: 40 ) ,
586- valueView. centerYAnchor. constraint ( equalTo: label. centerYAnchor) ,
587- valueView. trailingAnchor. constraint ( equalTo: contentView. trailingAnchor, constant: - 10 )
588- ] )
589- lastLabel = label
590- }
591-
592- let confirmButton = UIButton ( type: . system)
593- confirmButton. setTitle ( " Sure " . localized, for: . normal)
594- confirmButton. translatesAutoresizingMaskIntoConstraints = false
595- confirmButton. addTarget ( self , action: #selector( confirmAction) , for: . touchUpInside)
596-
597- alertView. addSubview ( confirmButton)
598-
599- NSLayoutConstraint . activate ( [
600- confirmButton. topAnchor. constraint ( equalTo: alertView. bottomAnchor, constant: - 40 ) ,
601- confirmButton. centerXAnchor. constraint ( equalTo: alertView. centerXAnchor)
602- ] )
603-
604- let lastView = lastLabel ?? contentView
605- NSLayoutConstraint . activate ( [
606- contentView. bottomAnchor. constraint ( equalTo: lastView. bottomAnchor, constant: 10 )
607- ] )
608-
609- self . present ( customAlertVC, animated: true , completion: nil )
610- }
611-
612- @objc func makeupSliderAction( _ view: UISlider ) {
613- let index = view. tag - 1000
614- let key = makeupList [ index] [ " key " ] as? String ?? " "
615- makeupParams [ key] = view. value
616-
617- if let label = view. superview? . viewWithTag ( index + 2000 ) as? UILabel {
618- label. text = String ( format: " %@[%.f] " , makeupList [ index] [ " name " ] as? String ?? " none " , view. value)
619- }
620- updateMakeup ( )
621- }
622-
623- @objc func makeupSwitchAction( _ view: UISwitch ) {
624- let index = view. tag - 1000
625- let key = makeupList [ index] [ " key " ] as? String ?? " "
626- makeupParams [ key] = view. isOn
627- updateMakeup ( )
628- }
629-
630- @objc func makeupSegmentAction( _ view: UISegmentedControl ) {
631- let index = view. tag - 1000
632- let key = makeupList [ index] [ " key " ] as? String ?? " "
633- makeupParams [ key] = view. selectedSegmentIndex
634- updateMakeup ( )
635- }
636-
637498 @objc func confirmAction( ) {
638499 self . dismiss ( animated: true , completion: nil )
639500 }
0 commit comments