0
A
回答
0
如果您想製作相同類型的視圖(如上圖所示),請在該部分的頁腳中放置一個標籤,使標籤的背景透明並根據您的選擇設置其框架,並添加文本你想放在那裏。讓我給你一個可能幫助你的代碼片段。
UILabel *tableFooter = [[UILabel alloc] initWithFrame:footerRect];
tableFooter.textColor = // add color of your choice
tableFooter.backgroundColor = // add color of your choice
tableFooter.opaque = YES;
tableFooter.font = [UIFont boldSystemFontOfSize:15];
tableFooter.text = @" add text of your choice";
self.theTable.tableFooterView = tableFooter;
[tableFooter release];
把上面的代碼中此方法:
- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
0
退房此委託方法:
- (NSString *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
2
這是寫在頁眉和UITableView中的頁腳。因此,請自定義表格中的部分的headerView和footerView。
使用以下方法:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
希望它可以幫助你。
0
你下面的方法它的工作對我來說我的應用程序:
- (void)viewDidLoad {
[super viewDidLoad];
/* ios 7 Change */
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.edgesForExtendedLayout = UIRectEdgeNone;
self.tableview.separatorInset = UIEdgeInsetsZero;
[self.tableview setSeparatorStyle:UITableViewCellSeparatorStyleNone];
}
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
NSString *header;
float start = 10.0, startLabel = 10.0;
if ([UICommonUtils isiPad])
{
startLabel = 50.0;
} else {
startLabel = 10.0;
}
CGRect rectFrame = [UIScreen mainScreen].applicationFrame;
UIView* customView = [[[UIView alloc]
initWithFrame:CGRectMake(start, 0.0, rectFrame.size.width - 20.0, 80.0)]
autorelease];
/*
customView.backgroundColor =
[UIColor colorWithRed:.6 green:.6 blue:1 alpha:.9];
*/
UILabel * headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
//UILabel * headerLabel = [[[UILabel alloc] initWithStyle:UITableViewCellStyleDefault] autorelease];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
//headerLabel.textColor = [UIColor darkGrayColor];
headerLabel.textColor = [UIColor colorWithRed:0.298039 green:0.337255 blue:0.423529 alpha:1];
headerLabel.shadowColor = [UIColor whiteColor];
headerLabel.shadowOffset = CGSizeMake(0.0, 1.0);
headerLabel.font = [UIFont boldSystemFontOfSize:17.0];
//headerLabel.frame = CGRectMake(startLabel, 0, rectFrame.size.width - 60.0, 20.0);
headerLabel.frame = CGRectMake(startLabel, 10, rectFrame.size.width - 35.0, 20.0);
headerLabel.textAlignment = UITextAlignmentLeft;
headerLabel.lineBreakMode = UILineBreakModeWordWrap;
headerLabel.text = header;
headerLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
UILabel * footerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
//UILabel *footerLabel = [[[UILabel alloc] initWithStyle:UITableViewCellStyleDefault] autorelease];
footerLabel.backgroundColor = [UIColor clearColor];
footerLabel.opaque = NO;
//footerLabel.textColor = [UIColor darkGrayColor];
footerLabel.textColor = [UIColor colorWithRed:0.298039 green:0.337255 blue:0.423529 alpha:1];
footerLabel.shadowColor = [UIColor whiteColor];
footerLabel.shadowOffset = CGSizeMake(0.0, 1.0);
footerLabel.font = [UIFont systemFontOfSize:14.0];
float height;
if ([UICommonUtils isiPad])
height = 40.0;
else
height = 50.0;
footerLabel.frame = CGRectMake(startLabel, 20, rectFrame.size.width - 60.0, height);
footerLabel.textAlignment = UITextAlignmentLeft;
footerLabel.lineBreakMode = UILineBreakModeWordWrap;
footerLabel.baselineAdjustment = UIBaselineAdjustmentNone;
footerLabel.numberOfLines = 0;
footerLabel.text = detail;
[customView addSubview:headerLabel];
[customView addSubview:footerLabel];
return customView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if ([UICommonUtils isiPad]) return 60.0;
else return 70.0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection: (NSInteger)section
{
return kProductHeader;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
/* ios 7 Change */
if ([cell respondsToSelector:@selector(tintColor)]) {
if (tableView == self.tableview) {
CGFloat cornerRadius = 5.f;
cell.backgroundColor = UIColor.clearColor;
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
CGMutablePathRef pathRef = CGPathCreateMutable();
CGRect bounds = CGRectInset(cell.bounds, 10, 0);
BOOL addLine = NO;
if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
} else if (indexPath.row == 0) {
CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds), CGRectGetMinY(bounds), cornerRadius);
CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
addLine = YES;
} else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), cornerRadius);
CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
} else {
CGPathAddRect(pathRef, nil, bounds);
addLine = YES;
}
layer.path = pathRef;
CFRelease(pathRef);
layer.fillColor = [UIColor colorWithWhite:1.f alpha:0.8f].CGColor;
if (addLine == YES) {
CALayer *lineLayer = [[CALayer alloc] init];
CGFloat lineHeight = (1.f/[UIScreen mainScreen].scale);
lineLayer.frame = CGRectMake(CGRectGetMinX(bounds)+10, bounds.size.height-lineHeight, bounds.size.width-10, lineHeight);
lineLayer.backgroundColor = tableView.separatorColor.CGColor;
[layer addSublayer:lineLayer];
}
UIView *testView = [[UIView alloc] initWithFrame:bounds];
[testView.layer insertSublayer:layer atIndex:0];
testView.backgroundColor = UIColor.clearColor;
cell.backgroundView = testView;
}
}
}
相關問題
- 1. 如何將圖像設置爲一個UITableView XCode中後臺視圖4.3.2
- 2. 在後臺捕獲視圖
- 3. 如何在從後臺返回後刷新桌面視圖
- 4. 如何在運行時更新UITableView,加載視圖後
- 5. 如何在UITableView選擇後推送加載視圖?
- 6. iOS:在後臺顯示視圖的UIWebView
- 7. 如何知道在後臺顯示UIViewController視圖的時間?
- 8. 在UITableView的配件視圖
- 9. 如何填充UIViewController子視圖的UITableView?
- 10. 如何在後臺加載36mb視頻
- 11. 如何在後臺播放視頻?
- 12. UITableView tableViewHeader後臺切斷
- 13. UITableView的子視圖?
- 14. 加載視圖後無法更新UITableView
- 15. 在後臺顯示具體視圖
- 16. 在後臺呈現視圖控制器
- 17. 在後臺加載OpenGl視圖。 iPhone
- 18. 在後臺加載web視圖
- 19. 充氣在後臺線程視圖
- 20. 如何填充子視圖子視圖的UITableView?
- 21. 如何在VSTO後臺視圖中屏蔽密碼?
- 22. 如何在加載列表視圖時實現後臺服務?
- 23. 如何在後臺「準備」一個視圖?
- 24. 如何在後臺刷新列表視圖?
- 25. 視圖在後臺線程上解除分配:如何調試?
- 26. 如何在後臺列表視圖中更改日期格式
- 27. 如何在視圖消失後保留UITableView中的複選標記
- 28. 如何在後臺下載表格視圖單元格的多個圖像?
- 29. 如何更新從後臺到前臺的表單時的DataGrid視圖?
- 30. 如何從android的後臺服務中獲取視圖?