Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 71

Djdios
Lost but trying
Profile
Posts: 175
Reg: Mar 20, 2013
Valby, Denmark
3,550
04/18/13 01:08 AM (12 years ago)

Rounded corners single row

Hi Is it still not possible to make one row with rounded corners? Can it be done in xcode? http://db.tt/bpguLNdk
 
Auggnet
Veteran developer
Profile
Posts: 225
Reg: Nov 20, 2012
USA
2,550
like
04/18/13 05:03 AM (12 years ago)
Im not sure, but it is a little annoying to me, but not enough to prevent or do anything about it, but thst's just me. Maybe have a look at the code where it defines the round corners.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
04/18/13 07:50 AM (12 years ago)
Easiest way to do that would be to use an image as the background for each table row. This code should work. I used it in the menusimpleadvanced plugin from BT Mods, but I believe the code is pretty much the same. Search for "//custom background view. Must be done here so we can retain the "round" corners if this is a round table" (around line 446) Comment out this line: [cell setBackgroundView:[BT_viewUtilities getCellBackgroundForListRow:[self screenData]:indexPath:[self.menuItems count]]]; Add this: [cell setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed: @"button.png"]]]; Where "button.png" is your image file.
 
Djdios
Lost but trying
Profile
Posts: 175
Reg: Mar 20, 2013
Valby, Denmark
3,550
like
04/18/13 08:55 AM (12 years ago)
Thank you very much, I'll take a look at it.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/18/13 01:45 PM (12 years ago)
Let's do some hacking In BT_viewUtilities.m replace the lines from 1158 to 1169 before //return with this below //position is important to maintain rounded corners if this is a "round" table. if(isRoundTable == FALSE){ bgView.position = CustomCellBackgroundViewPositionMiddle; }else{ if(theIndexPath.row == 0){ if(numRows == 1){ bgView.position = CustomCellBackgroundViewPositionSingle; }else{ bgView.position = CustomCellBackgroundViewPositionTop; } }else if(theIndexPath.row == numRows - 1){ bgView.position = CustomCellBackgroundViewPositionBottom; }else{ bgView.position = CustomCellBackgroundViewPositionMiddle; } } Then in theBT_cell_background view.m replace the whole -(void)drawRect:(CGRect)rect with the code below - (void)drawRect:(CGRect)rect { // Drawing code CGContextRef c = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(c, [fillColor CGColor]); CGContextSetStrokeColorWithColor(c, [borderColor CGColor]); if (position == CustomCellBackgroundViewPositionTop) { CGContextFillRect(c, CGRectMake(0.0f, rect.size.height - 10.0f, rect.size.width, 10.0f)); CGContextBeginPath(c); CGContextMoveToPoint(c, 0.0f, rect.size.height - 10.0f); CGContextAddLineToPoint(c, 0.0f, rect.size.height); CGContextAddLineToPoint(c, rect.size.width, rect.size.height); CGContextAddLineToPoint(c, rect.size.width, rect.size.height - 10.0f); CGContextStrokePath(c); CGContextClipToRect(c, CGRectMake(0.0f, 0.0f, rect.size.width, rect.size.height - 10.0f)); } else if (position == CustomCellBackgroundViewPositionBottom) { CGContextFillRect(c, CGRectMake(0.0f, 0.0f, rect.size.width, 10.0f)); CGContextBeginPath(c); CGContextMoveToPoint(c, 0.0f, 10.0f); CGContextAddLineToPoint(c, 0.0f, 0.0f); CGContextStrokePath(c); CGContextBeginPath(c); CGContextMoveToPoint(c, rect.size.width, 0.0f); CGContextAddLineToPoint(c, rect.size.width, 10.0f); CGContextStrokePath(c); CGContextClipToRect(c, CGRectMake(0.0f, 10.0f, rect.size.width, rect.size.height)); } else if (position == CustomCellBackgroundViewPositionSingle) { CGFloat minx = CGRectGetMinX(rect) , midx = CGRectGetMidX(rect), maxx = CGRectGetMaxX(rect) ; CGFloat miny = CGRectGetMinY(rect) , midy = CGRectGetMidY(rect) , maxy = CGRectGetMaxY(rect) ; minx = minx + 1; miny = miny + 1; maxx = maxx - 1; maxy = maxy - 1; CGContextMoveToPoint(c, minx, midy); CGContextAddArcToPoint(c, minx, miny, midx, miny, 10); CGContextAddArcToPoint(c, maxx, miny, maxx, midy, 10); CGContextAddArcToPoint(c, maxx, maxy, midx, maxy, 10); CGContextAddArcToPoint(c, minx, maxy, minx, midy, 10); // Close the path CGContextClosePath(c); // Fill & stroke the path CGContextDrawPath(c, kCGPathFillStroke); return; } else if (position == CustomCellBackgroundViewPositionMiddle) { CGContextFillRect(c, rect); CGContextBeginPath(c); CGContextMoveToPoint(c, 0.0f, 0.0f); CGContextAddLineToPoint(c, 0.0f, rect.size.height); CGContextAddLineToPoint(c, rect.size.width, rect.size.height); CGContextAddLineToPoint(c, rect.size.width, 0.0f); CGContextStrokePath(c); return; // no need to bother drawing rounded corners, so we return } // At this point the clip rect is set to only draw the appropriate // // corners, so we fill and stroke a rounded rect taking the entire rect CGContextBeginPath(c); addRoundedRectToPath(c, rect, 10.0f, 10.0f); CGContextFillPath(c); CGContextSetLineWidth(c, 1); CGContextBeginPath(c); addRoundedRectToPath(c, rect, 10.0f, 10.0f); CGContextStrokePath(c); } How easy was that, that question has been asked 100 times on these forums. A bit of welcome procrastination
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
04/18/13 02:03 PM (12 years ago)
Hey Kittsy, that looks great. I'll have to try it out and add it to my collection of hacks. Thanks.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.