-6

I want to make Custom UIview which have rounded cornes.

Is this possible?

Nimantha
  • 6,405
  • 6
  • 28
  • 69

4 Answers4

4

For this you need to import Quartz framework. You can also set Bordercolor, shadow color, corner width, etc to that view.

#import <QuartzCore/QuartzCore.h>

And try this code.

        [self.YourView.layer setCornerRadius:1.0];
        [self.YourView.layer setBorderColor:[[[UIColor grayColor] colorWithAlphaComponent:0.5] CGColor]];
        [self.YourView.layer setBorderWidth:1.0];
        [self.YourView.layer setShadowColor:[UIColor lightGrayColor].CGColor];
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Murali
  • 1,869
  • 1
  • 14
  • 22
2

Add This Framwork

#import "QuartzCore/QuartzCore.h" 


UIView *view = [[UIView alloc] initWithFrame:CGRectMake("As You Need")];
    view.backgroundColor = [UIColor whiteColor];
    view.layer.cornerRadius = 15.f; // set as u need
    view.layer.borderColor = [UIColor grayColor].CGColor; // set color as u need
    view.layer.borderWidth = 2.f; // set as u need
Nimantha
  • 6,405
  • 6
  • 28
  • 69
iPatel
  • 46,010
  • 16
  • 115
  • 137
0

First add QuartzCore Framework to your project.

Then import it into your class where you want to set your view corner radius,

#import <QuartzCore/QuartzCore.h>

Now make an IBOutlet in .h file to UIView (Assuming added by you in your XIB)

    IBOutlet UIView *backViewGroupName;

In your .m file,set sorner radius to your view

backViewGroupName.layer.cornerRadius=10.0;
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Aman Aggarwal
  • 3,754
  • 1
  • 19
  • 26
0

Import the QuartzCore Framework

#import <QuartzCore/QuartzCore.h>

then do this

View.layer.borderWidth = 3;
View.layer.cornerRadius = 10;
View.layer.masksToBounds = YES;

Don't forget masks to bound = yes.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Apple_iOS0304
  • 1,092
  • 1
  • 9
  • 19