CopyPastor

Detecting plagiarism made easy.

Score: 1.820462325288028; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Reposted on 2023-11-13
by Viktoryia

Original Post

Original - Posted on 2023-11-09
by Viktoryia



            
Present in both answers; Present only in the new answer; Present only in the old answer;

**** Rounded corners of the view and its selectedSegment ------------------------------------------------------------------------ ****
1. **Create a custom subclass of UISegmentedControl:**


final class SegmentedControl: UISegmentedControl { private var cornerRadius: CGFloat init(cornerRadius: CGFloat) { self.cornerRadius = cornerRadius super.init(frame: .zero) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func layoutSubviews() { super.layoutSubviews() layer.cornerRadius = cornerRadius guard let selectedSegment = subviews[numberOfSegments] as? UIImageView else { return } selectedSegment.image = nil selectedSegment.backgroundColor = selectedSegmentTintColor selectedSegment.layer.removeAnimation(forKey: "SelectionBounds") selectedSegment.layer.cornerRadius = cornerRadius - layer.borderWidth selectedSegment.bounds = CGRect(origin: .zero, size: CGSize( width: selectedSegment.bounds.width, height: bounds.height - layer.borderWidth * 2 )) } }
2. **Create an instance of SegmentedControl and don't forget to set `selectedSegmentTintColor`**
[Screenshot][1]

[1]: https://i.stack.imgur.com/iZZ0L.png
**Create a custom subclass of UISegmentedControl:**
final class SegmentedControl: UISegmentedControl { private var cornerRadius: CGFloat init(cornerRadius: CGFloat) { self.cornerRadius = cornerRadius super.init(frame: .zero) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func layoutSubviews() { super.layoutSubviews() layer.cornerRadius = cornerRadius guard let selectedSegment = subviews[numberOfSegments] as? UIImageView else { return } selectedSegment.image = nil selectedSegment.backgroundColor = selectedSegmentTintColor selectedSegment.layer.removeAnimation(forKey: "SelectionBounds") selectedSegment.layer.cornerRadius = cornerRadius - layer.borderWidth selectedSegment.bounds = CGRect(origin: .zero, size: CGSize( width: selectedSegment.bounds.width, height: bounds.height - layer.borderWidth * 2 )) } } **Create an instance of SegmentedControl and don't forget to set `selectedSegmentTintColor`**
[Screenshot][1]

[1]: https://i.stack.imgur.com/4cdji.png

        
Present in both answers; Present only in the new answer; Present only in the old answer;