【问题标题】:How to make a roundrect button overlay?如何制作圆形按钮覆盖?
【发布时间】:2012-08-03 00:13:50
【问题描述】:

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

- (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 的笔尖视图?

【问题讨论】:

标签: ios uibutton


【解决方案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
  • (如果您希望在 segue 之前完成额外的工作,请务必实施 prepareForSegue)

【讨论】:

    猜你喜欢
    • 2012-05-03
    • 1970-01-01
    • 2017-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多