2

I'm trying to change the Alpha of Selected and unselected carbonSegmentedControl items but didn't able to achieve that instead of whole carbonSegmentedControl alpha's changes. Sample code is as follow:

UIButton *firstButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/items.count-10, 43)];
firstButton.backgroundColor = [UIColor colorWithRed:0.0/255.0 green:75.0/255.0 blue:155.0/255.0 alpha:1.0];
firstButton.layer.borderWidth = 3.0;
firstButton.layer.borderColor = [UIColor whiteColor].CGColor;
[firstButton setTitle:buttonTitles[0] forState:UIControlStateNormal];
firstButton.titleLabel.font = [UIFont ProximaNova_Regular:16];


UIImage * firstButtonImage  = [self imageOfButton:firstButton];
//
UIButton *secondButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/items.count-10, 43)];
secondButton.backgroundColor = [UIColor colorWithRed:18.0/255.0 green:209.0/255.0 blue:193.0/255.0 alpha:1.0];
secondButton.layer.borderWidth = 3.0;
secondButton.layer.borderColor = [UIColor whiteColor].CGColor;
[secondButton setTitle:buttonTitles[1] forState:UIControlStateNormal];
secondButton.titleLabel.font = [UIFont ProximaNova_Regular:16];


UIImage *secondButtonImage  = [self imageOfButton:secondButton];
//
UIButton *thirdButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/items.count-10, 43)];
thirdButton.backgroundColor = [UIColor colorWithRed:251.0/255.0 green:252.0/255.0 blue:252.0/255.0 alpha:1.0];
thirdButton.layer.borderWidth = 3.0;
thirdButton.layer.borderColor = [UIColor colorWithRed:194.0/255.0 green:243.0/255.0 blue:237.0/255.0 alpha:1.0].CGColor;
[thirdButton setTitle:buttonTitles[2] forState:UIControlStateNormal];
thirdButton.titleLabel.font = [UIFont ProximaNova_Regular:16];
[thirdButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal
 ];

UIImage *thirdButtonImage  = [self imageOfButton:thirdButton];

imagesArray = [[NSArray alloc] initWithObjects:[firstButtonImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal],[secondButtonImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal],[thirdButtonImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal],nil];

carbonTabSwipeNavigation = [[CarbonTabSwipeNavigation alloc]
                            initWithItems:imagesArray
                            toolBar:_toolBar
                            delegate:self];
[carbonTabSwipeNavigation insertIntoRootViewController:self andTargetView:self.view];
carbonTabSwipeNavigation.carbonSegmentedControl.tintColor = [UIColor clearColor];

Is there any to accomplish this? Any relevant help will be welcome, Thanks.

Irfan
  • 4,301
  • 6
  • 29
  • 46

2 Answers2

1

By setting Aplha of carbonSegmentedControl items in the Carbobkit delegation carbonTabSwipeNavigation works for me:

-(void)carbonTabSwipeNavigation:(CarbonTabSwipeNavigation *)carbonTabSwipeNavigation didMoveAtIndex:(NSUInteger)index{

    carbonTabSwipeNavigation.carbonSegmentedControl.segments[index].alpha = 1.0;

 for (NSInteger i =0; i < carbonTabSwipeNavigation.carbonSegmentedControl.segments.count; i++) {
    if(i != index)
        carbonTabSwipeNavigation.carbonSegmentedControl.segments[i].alpha = 0.5;
  }
}
Irfan
  • 4,301
  • 6
  • 29
  • 46
0

you can change the colour of selected and normal Tab by using

 [carbonTabSwipeNavigation setSelectedColor:[[UIColor whiteColor] colorWithAlphaComponent:0.6]];
 [carbonTabSwipeNavigation setNormalColor:[[UIColor greenColor] colorWithAlphaComponent:1.0]];

where carbonTabSwipeNavigation is CarbonTabSwipeNavigation object

Nishant Bhindi
  • 2,242
  • 8
  • 21
  • can you please post your code what you have implemented. – Nishant Bhindi Aug 18 '17 at 08:48
  • change the carbonTabSwipeNavigation initialization to carbonTabSwipeNavigation = [[CarbonTabSwipeNavigation alloc] initWithItems: imagesArray delegate:self]; carbonTabSwipeNavigation.toolbar.translucent = NO; – Nishant Bhindi Aug 18 '17 at 10:44