uisegmentedcontrol

Change UISegmentedControl selected index or value programmatically

老子叫甜甜 提交于 2019-12-04 22:48:28
I have a UISegmentedControl with two segments (index: 0 and 1) that I am trying to reset programmatically to 0. When I run the command below it does not reset the segment index to 0 as expected. Instead it highlights segment indexed 1. [seg setSelectedSegmentIndex:0]; Oddly when I log the selected segment, it returns 0 . NSLog(@"seg setSelectedSegmentIndex %d", seg.selectedSegmentIndex); Also oddly, after running setSelectedSegmentIndex:0 I cannot reselect segment 0 manually by touch, it seems to be locked to segment 1, until I tap 1 wherein it works as normal. Here is the setup for the button

Swift handle action on segmented control

怎甘沉沦 提交于 2019-12-04 22:18:14
I have a HMSegmentedControl with 4 segments. When it is selected, it should pop up view. And when the pop up dismissed, and trying to click on same segment index it should again show the pop up. By using following does not have any action on click of same segment index after pop up dissmissed. segmetedControl.addTarget(self, action: "segmentedControlValueChanged:", forControlEvents: UIControlEvents.ValueChanged) You set your target to fire just when the value change, so if you select the same segment the value will not change and the popover will not display, try to change the event to

Change textColor in UISegmentedcontrol

若如初见. 提交于 2019-12-04 21:54:35
I use below code for change textcolor of each segmented in UISegmentedcontrol how can I change textcolor of specific segment?(for example segment at index 2) for (id seg in [segment subviews]) for (id label in [seg subviews]) if ([label isKindOfClass:[UILabel class]]) [label setTextColor:[UIColor redColor]]; i use below code for this problem int eg=0; for (id seg in [sg subviews]) { int gg=sg.selectedSegmentIndex; if(gg==2) gg=0; else if(gg==0) gg=2; if(eg==gg && eg!=1) { for (id label in [seg subviews]) if ([label isKindOfClass:[UILabel class]]) { [label setTextAlignment:UITextAlignmentCenter

Change border color of UISegmentedControl

喜你入骨 提交于 2019-12-04 21:46:26
I need different border colour for both the sections.By default I am having white as border color. Can anyone help me out with this? BHUVANESH MOHANKUMAR Extension method code for the Segment Control. This is working code with Latest Swift 3.0 [March 2017] The Extension method is created, as the extension to the native segment control. extension UISegmentedControl { func setSegmentStyle() { let segmentGrayColor = UIColor(red: 0.889415, green: 0.889436, blue:0.889424, alpha: 1.0 ) setBackgroundImage(imageWithColor(color: backgroundColor!), for: .normal, barMetrics: .default) setBackgroundImage

Make a segment of a segmented control invisible

扶醉桌前 提交于 2019-12-04 19:23:15
问题 Is it possible to make one segment of a segmented control invisible? 回答1: Though it seems there is no way to hide a segment in a segment control, you could remove a segment from the segment control using removeSegmentAtIndex:animated: method. You need either insertSegmentWithImage:atIndex:animated: or insertSegmentWithTitle:atIndex:animated: method to insert the segment again. Instead of hiding/showing a segment you could consider enabling/disabling it using setEnabled:forSegmentAtIndex:

Smooth Transition with UIPageViewController and UISegmentedControl like in Apple Music App

混江龙づ霸主 提交于 2019-12-04 19:22:24
In an app that im currently developing im switching between two UITableViewController's with a UISegmentedControl inside the UINavigationBar. The new Apple Music has a very neat effect where a user switches between UIViewController's inside a UIPageViewController. The associated UISegmentedControl adjusts smoothly to this. How should a basic storyboard setup or code base look to achieve something like this? you need to use uipageviewcontroller & uisegmentedcontrol in the following manner take uipageviewcontroller & see this tutorial for its integration http://www.appcoda.com

Weird interface bug UIScrollView in UITabBarController. Reproducible by others?

孤街浪徒 提交于 2019-12-04 15:51:12
I get a weird interface bug with my UIScrollView and I cant figure out how to solve it. I only wrote one line of code (shown below) and it is a blank project's setup easily reproducible ! Setting: I have a UIScrollView that contains a UISegmentedControl (since the segments of the control are loaded dynamically, it could exceed the width of the screen and the scrollView is supposed to scroll the segmentedControl horizontally, the height of the scrollview is the same as the UISegmentedControl's). The ViewController that contains this is embedded in a tabBar (or navigation bar, which also shows

Scroll dynamic UISegmentedControl in Swift 3

允我心安 提交于 2019-12-04 14:06:20
Hi i want to create a dynamic UISegmented View with more than 20 Items. I tried it, but the output is like this. the text is sliced not visible fully. I want it to scroll to the left and right and also display the full text. can some one help me to fix this. tnx View Controller override func viewDidLoad() { super.viewDidLoad() let items = ["All Fruits", "Orange", "Grapes", "Banana", "Mango", "papaya", "coconut", "django"] let filtersSegment = UISegmentedControl(items: items) filtersSegment.frame = CGRect.init(x: 10, y: 60, width: 300, height: 50) filtersSegment.selectedSegmentIndex = 0

Weird behavior with UISegmentedControl and UIAppearance

感情迁移 提交于 2019-12-04 12:35:31
问题 I am setting the appearance of the segmented control via these statements in the app delegate. [[UISegmentedControl appearance] setBackgroundImage:[[UIImage imageNamed:@"segmentation_normal.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0 , 0, 0)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [[UISegmentedControl appearance] setBackgroundImage:[[UIImage imageNamed:@"segmentation_selected.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0 , 0, 0)] forState

UISegmentedControl Behaviour

坚强是说给别人听的谎言 提交于 2019-12-04 09:58:45
A quick question about the UISegmentedControl class on the iPhone. Hopefully, some may have noticed how in its default state with 2 segments, the segmented control still will toggle even if the user taps on a segment that is currently selected. I've seen UISegmentedControls in apps that negate that behaviour and don't toggle when the user presses a selected segment. Namely, Apple's iTune Store app. Is there a simple way of preventing this behaviour that I'm overlooking, or do I need to write some logic into the valueChanged? I've been trying to disable currently selected segments and enabling