There is an UISegmentedControl
in a navigationBar
, which created in the Storyboard
and have an Outlet
wired to it. I have tried to add a custom badge to the UISegmentedControl
, but failed. The badge does not appear.
Ps. The custom badge appears when i add it to the navigationBar
(the superview of the UISegmentedControl
), but it is the second approach for me. I wanna add it directly to the UISegmentedControl
, could I?
MyTableViewController.h
...
@interface MyTableViewController : UITableViewController{
}
@property (strong,nonatomic) IBOutlet UISegmentedControl *segmentedControl;
...
MyTableViewController.m
@synthesize segmentedControl;
...
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
CustomBadge *customBadge = [CustomBadge customBadgeWithString:@"1" withStringColor:[UIColor whiteColor] withInsetColor:[UIColor orangeColor] withBadgeFrame:YES withBadgeFrameColor:[UIColor whiteColor] withScale:0.8 withShining:YES];
NSLog(@"self.segmentedControl :%@",self.segmentedControl);
NSLog(@"self.segmentedControl w: %f, h :%f",self.segmentedControle.frame.size.width, self.segmentedControlle.frame.size.height);
NSLog(@"customBadge x: %f, y: %f, w: %f, h :%f", customBadge.frame.origin.x, customBadge.frame.origin.y,customBadge.frame.size.width, customBadge.frame.size.height);
[self.segmentedControl addSubview:customBadge];
}
...
log results:
self.segmentedControl :<UISegmentedControl: 0x3b7bf0; frame = (83 7; 154 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x3b7c70>>
self.segmentedControl w: 154.000000, h :30.000000
customBadge x: 0.000000, y: 0.000000, w: 20.000000, h :20.000000
the CustomBadge
is the third party custom badge view class.