0

每次加载我的相机预览屏幕时,都会出现下面的叠加层。我想在覆盖层上创建一个圆形矩形按钮,以编程方式命名为“完成”。我该怎么做?

- (UIView*)CommomOverlay {

    UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,430)];
    UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,430)];

    [FrameImg setImage:[UIImage imageNamed:@"newGraphicOverlay.png"]];
    FrameImg.userInteractionEnabled = YES;

    [view addSubview:FrameImg];

    return view;
}

另外,我会在我的finishButtonPressed方法中添加什么来显示一个名为 nib 的视图testviewcontroller

4

1 回答 1

1

1.) 这是一个添加到视图中心的蓝色按钮:

UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,430)];
UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,430)];

[FrameImg setImage:[UIImage imageNamed:@"newGraphicOverlay.png"]];
FrameImg.userInteractionEnabled = YES;

[view addSubview:FrameImg];

UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 150, 50)];
button.center = view.center;
button.backgroundColor = [UIColor blueColor];
button.layer.cornerRadius = 10.0;
button.titleLabel.text = @"Finished";

[view addSubview:button];

2.) 你应该:

  • 在情节提要中附加一个转场
  • 命名segue标识符
  • 调用 performSegueWithIdentifier
  • (一定要实现prepareForSegue,如果你想在segue之前做额外的工作)
于 2016-06-24T16:28:44.540 回答