如何制作圆形按钮叠加?

时间:2012-08-03 00:13:51

标签: ios uibutton

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

- (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方法中添加什么来显示名为testviewcontroller的笔尖的视图?

1 个答案:

答案 0 :(得分: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
  • 命名segue标识符
  • 调用performSegueWithIdentifier
  • (如果你想在segue之前完成额外的工作,一定要实现prepareForSegue)