Change the angular radius of a uitableview grouped in iOS6

I tried using the following code but no luck. Does anyone know how to do this in iOS 6? I do not want to create a custom cell.

self.tableView.layer.cornerRadius = 5.0f; [self.tableView setClipsToBounds:YES]; 

Edit:

It seems that what actually happens is that this code creates an angle radius for the entire view, and not for each individual UITableViewSection. It makes sense?

I also tried [cell.layer setCornerRadius:3.0]; but also no luck. The corners of my UITableView are the same anyway.

enter image description here

+6
source share
10 answers

You can change the backgroundView of the TableViewCell, subclass the UIView, and change the layer class:

 @interface BackgroundView : UIView @end @implementation BackgroundView + (Class)layerClass { return [CAShapeLayer class]; } @end 

later in cellForRowAtIndexPath you will do something like this:

 static NSString *CellIdentifier = @"CustomCell"; CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; CGRect frame = cell.backgroundView.frame; cell.backgroundView = [[BackgroundView alloc] initWithFrame:frame]; CGFloat corner = 20.0f; UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:cell.backgroundView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(corner, corner)]; CAShapeLayer *shapeLayer = (CAShapeLayer *)cell.backgroundView.layer; shapeLayer.path = path.CGPath; shapeLayer.fillColor = cell.textLabel.backgroundColor.CGColor; shapeLayer.strokeColor = [UIColor lightGrayColor].CGColor; shapeLayer.lineWidth = 1.0f; return cell; 

Result:

enter image description here

You can change the desired angles or create a different path.

Hope this helps.

+19
source

who said that [_tblView.layer setCornerRadius:10.0]; does not work in a grouped style tableView.

Write this code, and you set setCornerRadius also works in a grouped tableView.

 [_tblView setBackgroundView:nil]; [_tblView setBackgroundColor:[UIColor greenColor]]; [_tblView.layer setCornerRadius:10.0]; 

enter image description here

[_tblView.layer setCornerRadius:10.0]; will not create an angular radius for a specific section of the tableView, this is to set the radius of the angle of the entire tableView.

+4
source

Add this to your .h file

 #import <QuartzCore/QuartzCore.h> 

And use below in your code,

 tblView.layer.cornerRadius=5.0f; 
+3
source

instead of setting the radius of the corner of the cell, set the radius for cell.contentview as follows:

 cell.contentView.layer.cornerRadius = 10.0f; cell.contentView.layer.borderColor = [UIColor blackColor].CGColor; cell.contentView.layer.borderWidth = 3.0f; 

put the above code during cell initialization.

+3
source

add quartzcore framework project to the project

 import QuartzCore/QuartzCore.h to your .h file 

self.tableView.layer.cornerRadius = 5.0f;

+2
source

I think you are missing this line of code:

 [self.tableView.layer setMasksToBounds:YES]; 
+2
source

First you need to use the QuartzCode Framework Import, which Framework ANd declares .h file. What class did you want to set the layer effect.

And add this method

 myTableView.layer.cornerRadius=5; [myTableView setClipsToBounds:YES]; 

and if you want to set the angular radiation into the cell, try this code

UITableViewCell.layer is a class of the CALayer class, and the CALayer class has the cornerRadius property. so you set the cell radius as vapors:

 [cell.layer setCornerRadius:3.0]; 

Try this code.

+2
source

You can do it. His work is for me

  UILabel *delLbl = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 300, 44)]; delLbl.font = [UIFont fontWithName:@"Arial-BoldMT" size:18]; delLbl.layer.cornerRadius = 10.0f; delLbl.layer.borderWidth = 1.0f; delLbl.layer.borderColor = [UIColor grayColor].CGColor; delLbl.text = @"Cell Text"; delLbl.textAlignment = NSTextAlignmentCenter; [cell.contentView addSubview:delLbl]; cell.backgroundView = [[UIView alloc] initWithFrame:CGRectZero]; Return Cell; 
+2
source

I think PrettyKit is what you are looking for. Fully customizable and fast. https://github.com/vicpenap/PrettyKit to let him know. Must do the job properly.

+2
source

Try the following: -

 tableView.layer.cornerRadius=5.0f; 
+1
source

Source: https://habr.com/ru/post/951184/


All Articles