Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border is overlapping on view : how to set superview opaque

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.

enter image description here

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];
like image 609
Arpit B Parekh Avatar asked Nov 17 '25 01:11

Arpit B Parekh


1 Answers

 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];
like image 172
Hector Avatar answered Nov 19 '25 15:11

Hector