我正在使用 ARKit API ...我想在右侧的框中添加自定义 UIButton,该框出现在由应用程序委托中的以下代码生成的屏幕上:
#define BOX_WIDTH 350
#define BOX_HEIGHT 150
- (UIView *)viewForCoordinate:(ARCoordinate *)coordinate {
CGRect theFrame = CGRectMake(0, 0, BOX_WIDTH, BOX_HEIGHT);
UIView *tempView = [[UIView alloc] initWithFrame:theFrame];
//tempView.backgroundColor = [UIColor colorWithWhite:.5 alpha:.3];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, BOX_WIDTH, 20.0)];
titleLabel.backgroundColor = [UIColor colorWithWhite:.3 alpha:.8];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.textAlignment = UITextAlignmentCenter;
titleLabel.text = coordinate.title;
[titleLabel sizeToFit];
titleLabel.frame = CGRectMake(BOX_WIDTH / 2.0 - titleLabel.frame.size.width / 2.0 - 4.0, 0, titleLabel.frame.size.width + 8.0, titleLabel.frame.size.height + 8.0);
UIImageView *pointView = [[UIImageView alloc] initWithFrame:CGRectZero];
pointView.image = [UIImage imageNamed:@"location.png"];
pointView.frame = CGRectMake((int)(BOX_WIDTH / 2.0 - pointView.image.size.width / 2.0), (int)(BOX_HEIGHT / 2.0 - pointView.image.size.height / 2.0), pointView.image.size.width, pointView.image.size.height);
[tempView addSubview:titleLabel];
[tempView addSubview:pointView];
[titleLabel release];
[pointView release];
return [tempView autorelease];
}
我怎样才能做到这一点?请帮忙 !