BetterSegmentedControl icon indicating copy to clipboard operation
BetterSegmentedControl copied to clipboard

Please add spacing lines

Open kacok opened this issue 5 years ago • 1 comments

such as A | B | C | D

kacok avatar Dec 21 '20 08:12 kacok

You can add lineview to normalView. But it's not very convenient. Like this:

     lazy var segmentedControl = BetterSegmentedControl().then {
        $0.backgroundColor = .white
        
        var mArr = [BetterSegmentedControlSegment]()
        // left
        let leftSegment = IconSegment(icon: R.image.cut_minus_icon()!, iconSize: CGSize(width: 10, height: 1), normalIconTintColor: .black, selectedIconTintColor: .black)
        let line1 = UIView()
        line1.frame = CGRect(x: 123/3 - 2, y: 0, width: 2, height: 30)
        line1.backgroundColor = .black
        leftSegment.normalView.addSubview(line1)
        
        mArr.append(leftSegment)
                                
        // center
        mArr.append(LabelSegment(text: "0"))
        
        // right
        let rightSegment = IconSegment(icon: R.image.cut_minus_icon()!, iconSize: CGSize(width: 10, height: 1), normalIconTintColor: .black, selectedIconTintColor: .black)
        let line2 = UIView(frame: CGRect(x: 0, y: 0, width: 2, height: 30))
        line2.backgroundColor = .black
        rightSegment.normalView.addSubview(line2)
        
        mArr.append(rightSegment)
        
        
        $0.segments = mArr
        $0.indicatorViewBackgroundColor = .clear
                
        $0.backgroundColor = .white
        $0.layer.borderColor = UIColor.black.cgColor
        $0.layer.borderWidth = 1
        
        $0.cornerRadius = 8
        
        $0.addTarget(self, action: #selector(segmentedControlChanged(_ :)), for: .valueChanged)
    }

roMummy avatar Sep 07 '21 07:09 roMummy