-1
我目前加入任何一個在我UITableView
節的頁腳向上或向下箭頭的圖像,像這樣:如何在UITableView部分頁腳中水平居中放置UIView?
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.backgroundColor = [UIColor whiteColor];
MoreButton *moreButton = [MoreButton buttonWithType:UIButtonTypeCustom];
moreButton.frame = CGRectMake(0, 0, 60, 22);
moreButton.sectionIndex = section;
if (self.expandedSection == -1){
[moreButton setImage:[UIImage imageNamed:@"DownArrow.png"] forState:UIControlStateNormal];
}
else {
if (self.expandedSection == section) {
[moreButton setImage:[UIImage imageNamed:@"UpArrow.png"] forState:UIControlStateNormal];
}
else {
[moreButton setImage:[UIImage imageNamed:@"DownArrow.png"] forState:UIControlStateNormal];
}
}
[moreButton addTarget:self action:@selector(moreButtonSelected:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:moreButton];
return view;
這工作得很好,除了一個事實,即它位於左側一路圖像,同時,我希望它是在中間:
我知道這是因爲我給幀(CGRectMake(0, 0, 60, 22);
)的定位的,但我不知道如何設置的x座標有無論屏幕大小如何,它都是水平居中的。