In my app,
I am taking one button
and adding a red label as a subview on it.
But the border of button is overlapping on border see the image.

Here is mycode.
Category means green boxed button
And red box is a UILabel
I think I
Category *category=[[Category alloc] initWithName:[dict valueForKey:@"category_name"] identity:[[dict valueForKey:@"category_id"] intValue] imageName:nil];
//Button Formatting.
[category setBackgroundColor:[UIColor colorWithRed:126.0/255.0 green:187.0/255.0 blue:75.0/255.0 alpha:1.0]];
[[category layer] setBorderWidth:3.0];
[[category layer] setBorderColor:[[UIColor grayColor] CGColor]];
/*Label Formatting.*/
category.lblimagesCount=[[UILabel alloc] initWithFrame:CGRectMake(category.frame.size.width-22, category.frame.origin.y-18, 26, 26)];
[category.lblimagesCount setBackgroundColor:[UIColor redColor]];
[[category.lblimagesCount layer] setBorderWidth:2.0];
[[category.lblimagesCount layer] setBorderColor:[[UIColor whiteColor] CGColor]];
[category.lblimagesCount setFont:[UIFont boldSystemFontOfSize:18]];
[category.lblimagesCount setTextColor:[UIColor whiteColor]];
[[category.lblimagesCount layer] setOpacity:1.0];
[category.lblimagesCount setTextAlignment:UITextAlignmentCenter];
[category addSubview:category.lblimagesCount];
[self.viewHeader addSubview:category];
category.lblimagesCount.center=CGPointMake(category.frame.origin.x+category.frame.size.width, category.frame.origin.y);
add this and in the last add this
[self.viewHeader addSubview:category];
[self.viewHeader addSubview:category.lblimagesCount];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With