我正在实现一个页脚视图,它是一个 UIView,它里面有一个标签。我想要它让 UILabel 一直保持在中心,但它不会。这是我的代码:
- (void)setupFooterView
{
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.scrollView_.frameWidth, kFooterViewHeight)];
[footerView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth];
[footerView setBackgroundColor:[UIColor clearColor]];
UILabel *loadMoreLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[loadMoreLabel setBackgroundColor:[UIColor clearColor]];
[loadMoreLabel setFont:[UIFont fontWithName:kProximaNova size:16]];
[loadMoreLabel setTextColor:[UIColor whiteColor]];
[loadMoreLabel setLineBreakMode:UILineBreakModeTailTruncation];
CGSize desiredSize = [[PNRConstants kLoadingMore] sizeWithFont:loadMoreLabel.font constrainedToSize:CGSizeMake(footerView.frameWidth, footerView.frameHeight) lineBreakMode:loadMoreLabel.lineBreakMode];
[loadMoreLabel setFrameSize:desiredSize];
[loadMoreLabel setCenter:CGPointMake(footerView.frameWidth/2, footerView.frameHeight/2)];
self.loadingMoreLabel_ = loadMoreLabel;
[footerView addSubview:self.loadingMoreLabel_];
[loadMoreLabel release];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[spinner setBackgroundColor:[UIColor clearColor]];
[spinner setFrameX:self.loadingMoreLabel_.frameX - spinner.frameWidth - 10];
[spinner setFrameY:self.loadingMoreLabel_.frameY];
self.spinner_ = spinner;
[footerView addSubview:self.spinner_];
[spinner release];
[self.scrollView_ setFooterView_:footerView];
[footerView release];
}
我在这里做错了什么?