how to change font size and font name of uisegmentedcontrol programmatically on swift?

UI can use control appearance, best place to add it is in app delegate, didFinishLaunchingWithOptions method, use this if you want to set up the same attribute to every UISegmentedControls in your project just once: let attr = NSDictionary(object: UIFont(name: “HelveticaNeue-Bold”, size: 16.0)!, forKey: NSFontAttributeName) UISegmentedControl.appearance().setTitleTextAttributes(attr as [NSObject : AnyObject] , forState: .Normal) But if … Read more

Swift handle action on segmented control

You can add the same target for multiple events. So lets say your segmentedControlValueChanged: looks like this: @objc func segmentedControlValueChanged(_ sender: UISegmentedControl) { if sender.selectedSegmentIndex == 0 { // value for first index selected here } } Then you can add targets for more than 1 events to call this function: segmentedControl.addTarget(self, action: #selector(segmentedControlValueChanged(_:)), for: … Read more

UISegmentedControl register taps on selected segment

You can subclass UISegmentedControl, and then override setSelectedSegmentIndex: – (void) setSelectedSegmentIndex:(NSInteger)toValue { if (self.selectedSegmentIndex == toValue) { [super setSelectedSegmentIndex:UISegmentedControlNoSegment]; } else { [super setSelectedSegmentIndex:toValue]; } } If using IB, make sure you set the class of your UISegmentedControl to your subclass. Now you can listen for the same UIControlEventValueChanged as you would normally, except if … Read more

Define click event for UISegmentedControl

If I understand your question correctly, you simply have to implement a target-action method (supported by UIControl which is UISegmentedControl‘s parent class) for the constant UIControlEventValueChanged, exactly like in the example given in UISegmentControl’s reference documentation. i.e. [segmentedControl addTarget:self action:@selector(action:) forControlEvents:UIControlEventValueChanged]; used for a message with the following signature: – (void)action:(id)sender or [segmentedControl addTarget:self action:@selector(action:forEvent:) … Read more

How to programmatically add a UISegmentedControl to a container view

this one is perfect I tested….. UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 435)]; scroll.contentSize = CGSizeMake(320, 700); scroll.showsHorizontalScrollIndicator = YES; NSArray *itemArray = [NSArray arrayWithObjects: @”One”, @”Two”, @”Three”, nil]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; segmentedControl.frame = CGRectMake(35, 200, 250, 50); segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain; [segmentedControl addTarget:self action:@selector(MySegmentControlAction:) forControlEvents: UIControlEventValueChanged]; segmentedControl.selectedSegmentIndex = 1; [scroll … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)