我需要在我的视图中有一个页脚说“Powered by:{image_logo_of_my_company}”我如何实现这一目标?
答案 0 :(得分:4)
制作UIView
类型的包装器视图,并在该视图内的UILabel
内的适当坐标处添加UIImageView
和徽标。
UIView *wrapper = [[UIView alloc] initWithFrame:footerFrame];
UILabel *label = [[UILabel alloc] initWithFrame:
CGRectMake(0, 0, footerFrame.size.width*0.6, footerFrame.size.height)];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:
CGRectMake(footerFrame.size.width*0.6, 0,
footerFrame.size.width*(1.0-0.6), footerFrame.size.height)];
[wrapper addSubView:label];
[wrapper addSubView:imageView];
label.text = @"Powered by: ";
imageView.image = [UIImage imageNamed:@"logo"]; // assumes logo.png & logo@2x.png
[viewNeedingFooter addSubView:wrapper];
假设您需要标签宽度的60%和徽标的40%。