2012-08-03 148 views
0

我有下面的叠加层,每当我的相机预览屏幕加载时出现。我想在覆盖图上以编程方式创建一个名为“Finished”的圆形矩形按钮。我该怎么做?如何制作一个圆形的按钮覆盖?

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

+0

http://stackoverflow.com/questions/1210408/iphone-dev-create-uibutton-manually http://stackoverflow.com/questions/2072888/how-do- i-create-uiviewcontroller-using-xib-file – 2012-08-03 00:32:17

+0

你在这里问两个完全不相关的问题,这在这种格式下并不真正起作用。 (http://meta.stackexchange.com/questions/39223/one-post-with-multiple-questions-or-multiple-posts)你可能会得出一个正确和不正确的答案。将它们分成两个单独的问题。 – 2012-08-03 01:23:10

回答

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,如果你想额外的w ork在赛季之前完成)