iPhone UIView with Border | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

iPhone UIView with Border

Wednesday

Adding border to UITextView - in  iPhone SDK:
                                         This is a sample for add border arround with a UIView in  an iphone application (Ref screen shot ). Here I'm using an image view to set  round background in iphone Apps. You just copy and paste the following in to inside your page's ViewDidLoad method (You can change dimensions ).
Don't forget to import  the QuartzCore framework  (#import QuartzCore/QuartzCore.h)
Coding
- (void)viewDidLoad {
        [super viewDidLoad];
 [self.view setBackgroundColor:[UIColor whiteColor]];
 //Create a Imageview
 UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 2, 600, 600)];

 //Enable maskstobound so that corner radius would work.
 [imageView.layer setMasksToBounds:YES];
 //Set the corner radius
 [imageView.layer setCornerRadius:10.0];
 //Set the border color
 [imageView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
 //Set the image border
 [imageView.layer setBorderWidth:1.0]; 
 UIView * loadingView = [[UIView alloc] initWithFrame:CGRectMake(5, 2, 300, 250)];
 [loadingView setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0]];
 
 //Enable maskstobound so that corner radius would work.
 [loadingView.layer setMasksToBounds:YES];
 //Set the corner radius
 [loadingView.layer setCornerRadius:10.0];
 //Set the border color
 [loadingView.layer setBorderColor:[[UIColor blackColor] CGColor]];
 //Set the image border
 [loadingView.layer setBorderWidth:1.0];
  
 //Add the loadingView as a subview to imageView
 [imageView addSubview:loadingView];
 [loadingView release];
 
 //Add the imageview as a subview to main view
 [self.view addSubview:imageView];
 [imageView release];
    [super viewDidLoad];
}

Sample screen:


                                                       

0 comments:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets