UITableView에 대한 인덱스/카운트 버튼을 만들 수 있습니까?인덱스/개수에 대한 TableView 타원형 단추
iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpgApple 예제 또는 다른 자습서가 있습니까? 감사, 요르단
UITableView에 대한 인덱스/카운트 버튼을 만들 수 있습니까?인덱스/개수에 대한 TableView 타원형 단추
iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpgApple 예제 또는 다른 자습서가 있습니까? 감사, 요르단
와우 ... AAA ... 좋아 ... 나는 더 쉬운 방법이있어 : 기본적으로
#import <QuartzCore/QuartzCore.h>
.....
UILabel *label = [[UILabel alloc] initWithFrame:
CGRectMake(cell.contentView.frame.size.width - 50, 0, 35, 35)];
label.layer.cornerRadius = 5;
label.backgroundColor = [UIColor blueColor]; //feel free to be creative
label.clipToBounds = YES;
label.text = @"7"; //Your text here
[cell.contentView addSubview: label];
[label release];
, 당신이 만들고있어를 UILabel의를 사용하여 모서리가 둥근 QuartzCore 프레임 워크 - 그것을 포함하는 것을 잊지 마십시오. 추가 참고 사항 : OS> 3.0에서만 작동합니다.
사용자 정의보기를 만든 다음 수동으로 타원과 숫자를 그려야합니다. 마지막으로 해당 사용자 정의보기를 셀의 부속보기로 지정하십시오. 다음은 Core Graphics를 사용하는 드로잉 코드입니다. 너무 까다로운 아니다 :
CGRect bounds = self.bounds;
CGContextRef context = UIGraphicsGetCurrentContext();
float radius = bounds.size.height/2.0;
NSString *countString = [NSString stringWithFormat: @"%d", _count];
if (_count < 100) bounds = CGRectMake(5, 0, bounds.size.width - 10, bounds.size.height);
CGContextClearRect(context, bounds);
CGContextSetFillColorWithColor(context, _color.CGColor);
CGContextBeginPath(context);
CGContextAddArc(context, radius + bounds.origin.x, radius, radius, M_PI/2 , 3 * M_PI/2, NO);
CGContextAddArc(context, (bounds.size.width + bounds.origin.x) - radius, radius, radius, 3 * M_PI/2, M_PI/2, NO);
CGContextClosePath(context);
CGContextFillPath(context);
[[UIColor whiteColor] set];
UIFont *font = [UIFont boldSystemFontOfSize: 14];
CGSize numberSize = [countString sizeWithFont: font];
bounds.origin.x += (bounds.size.width - numberSize.width)/2;
[countString drawInRect: bounds withFont: font];
루비 에르, 당신의 방법 바위! – Jordan