polqf / twicketsegmentedcontrol Goto Github PK
View Code? Open in Web Editor NEWCustom UISegmentedControl replacement for iOS, written in Swift
License: MIT License
Custom UISegmentedControl replacement for iOS, written in Swift
License: MIT License
Also setting slider sliderBackgroundColor does not change color for me
import UIKit
import TwicketSegmentedControl
import SnapKit
class PendingActionViewController: UIViewController,TwicketSegmentedControlDelegate {
var segmentControlView:UIView = {
var uiView = UIView()
uiView.backgroundColor = UIColor.init(red: 0/255.0, green: 102/255.0, blue: 204/255.0, alpha: 1.0)
return uiView
}()
var contentView:UIView = {
var uiView = UIView()
return uiView
}()
var twicketSegmentControl:TwicketSegmentedControl = {
var twicketSegmentControl : TwicketSegmentedControl = TwicketSegmentedControl(frame:CGRect.zero)
let titles = ["Messages(4)", "Orders(0)", "Shipments(1)"]
twicketSegmentControl.setSegmentItems(titles)
twicketSegmentControl.highlightTextColor = UIColor.white
twicketSegmentControl.defaultTextColor = UIColor.white
twicketSegmentControl.sliderBackgroundColor = UIColor.init(red: 26/255.0, green: 153/255.0, blue: 255/255.0, alpha: 1.0)
twicketSegmentControl.segmentsBackgroundColor = UIColor.red
return twicketSegmentControl
}()
override func viewDidLoad() {
self.title = "Pending Items"
super.viewDidLoad()
configureViewHierarchy()
}
func configureViewHierarchy(){
view.addSubview(segmentControlView)
segmentControlView.snp.makeConstraints { (make) in
make.top.left.right.equalTo(view)
}
segmentControlView.addSubview(twicketSegmentControl)
twicketSegmentControl.delegate = self;
twicketSegmentControl.snp.makeConstraints { (make) in
make.top.equalTo(segmentControlView).offset(10)
make.left.equalTo(segmentControlView).offset(16)
make.right.equalTo(segmentControlView).offset(-16)
make.bottom.equalTo(segmentControlView).offset(-10)
make.height.equalTo(40)
}
view.addSubview(contentView)
contentView.snp.makeConstraints { (make) in
make.left.right.equalTo(view)
make.bottom.equalTo(view)
make.top.equalTo(segmentControlView.snp.bottom)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func didSelect(_ segmentIndex: Int) {
print("Selected index: \(segmentIndex)")
}
}
I'm facing some issues when I user
self.segMentView.move(to: 0)
segment index only moved to the corresponding index but delegate not triggered can you kindly do need fully
When ever I slide it doesn't stay in it's selected Index, it moves to first index
Thanks for your awesome library! I'm running into a bug where the selected segment background color persists sometimes after moving it to another segment (see below). Please help!
Code for implementation is below:
let segmentedControlTitles = ["Assistant","Itinerary","Chat"]
segmentedControl = TwicketSegmentedControl(frame: CGRect(x: UIScreen.main.bounds.width / 2 - 135, y: 20, width: 270, height: 40))
segmentedControl?.setSegmentItems(segmentedControlTitles)
segmentedControl?.delegate = self
segmentedControl?.segmentsBackgroundColor = UIColor.clear
segmentedControl?.isSliderShadowHidden = false
segmentedControl?.backgroundColor = .clear // This is important!
Everything works in regards to the segmented control displaying the correct view (aka container). My issue is that in the container view, user can not interact with any elements as simple as text fields, uipicker, etc... basically anything but Images and Labels!?
Please god support swift 4
Does this work with swift 2.2 ? or do i have to use Swift 3 for this cocoapod or library to work ?
I'm wondering if it's at all possible to add a blur view to the background view. From what I understand, if a mask is set to a superview of a UIVisualEffectView it will fail as mentioned here: https://developer.apple.com/reference/uikit/uivisualeffectview. Not sure if this is the cause of the failure I get when I try.
If there a way to use little images / icons (with or without text) with this component?
Any changes to support it on iOS 9, because supporting only on iOS 10 is too restrictive by now.
When running program I get Thread 1: EXC_BAD_ACCESS (code=2, address=0x102e24e58) pointing at the setSegmentItems
Hi great framework you have made. I have installed the TwicketSegmentedControl and used the delegate after the class declaration. I use the func didSelect(_ segmentIndex: Int) but it does not react to changes. Can you update your example with the implementation please?
Looks like this will never be set to a new value as its always set to background color in setter
open var segmentsBackgroundColor: UIColor = Palette.segmentedControlBackgroundColor {
didSet {
backgroundView.backgroundColor = backgroundColor
}
}
Unable to increase height of segmented control, could anyone help me in this?
Hi, just wondering if this lib will add support for Swift 4? Thanks!
Everything is working on DidSelect, but when I call tableview.reload the tableview reloads with the correct data but the segmented control stays on index[0] even though the print says index[1]. I only have two titles on the segementedControl.
When I select index[1] the segment jumps to it and immediately switches back to index[0].
I have create two TwicketSegment. How can i use different didSelect functions? I can´t use .addTarget method on my created segments. Please help me
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.