Iphone 如何以编程方式制作UIToolbar覆盖?
我的大部分相机覆盖屏幕都被不透明覆盖层覆盖。对于剩下的部分,我想添加一个带有几个按钮的Iphone 如何以编程方式制作UIToolbar覆盖?,iphone,ios,xcode,Iphone,Ios,Xcode,我的大部分相机覆盖屏幕都被不透明覆盖层覆盖。对于剩下的部分,我想添加一个带有几个按钮的UIToolbar。请务必提及如何使这些按钮也可通过编程方式单击 下面是我如何添加我的覆盖,它看起来非常完美 - (UIView*)CommomOverlay { //Both of the 428 values stretch the overlay bottom to top for overlay function. It doesn't cover it. UIView* view
UIToolbar
。请务必提及如何使这些按钮也可通过编程方式单击
下面是我如何添加我的覆盖,它看起来非常完美
- (UIView*)CommomOverlay {
//Both of the 428 values stretch the overlay bottom to top for overlay function. It doesn't cover it.
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,428)];
UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,428)];
[FrameImg setImage:[UIImage imageNamed:@"newGraphicOverlay.png"]];
[view addSubview:FrameImg];
return view;
}
类似地,我将如何添加一个工作工具栏(可单击且功能齐全,上面有两个按钮) 试试这个:(在你的视图中加载,或者视图将出现)
- 创建如下选择器:
-(void)button1Tap:(id)sender { NSLog(@"Button 1 was tapped!"); // do whatever needs to happen }
UIToolBar
:
- (UIView*)CommomOverlay {
//Both of the 428 values stretch the overlay bottom to top for overlay function. It doesn't cover it.
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,428)];
UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,428)];
[FrameImg setImage:[UIImage imageNamed:@"newGraphicOverlay.png"]];
UIToolbar *myToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UIBarButtonItem *myBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(myFunction)];
[myToolBar setItems:[NSArray arrayWithObjects:myBarButtonItem, nil] animated:YES];
[FrameImg addSubview:myToolBar];
[view addSubview:FrameImg];
return view;
}
什么是摄像头覆盖屏幕?@tiguero我猜他指的是UIImagePickerController.cameraOverlayView。非常感谢,这很有帮助!但我还有一个问题,希望你能提供一些见解。我在自定义工具栏上创建了一个“完成”按钮。我使用的ZBar SDK允许我扫描条形码,默认版本在一个条形码后停止扫描,并显示条形码结果。我想扫描多个条形码,当我点击UIToolBar上的“完成”按钮时,我想关闭UIImagePickerController。很高兴它起到了作用。最好将其作为一个单独的问题发布,这样对其他人也会很有用……非常感谢,这是一个很好的见解!现在请您回答我的其他问题(请查看我的个人资料)?
- (UIView*)CommomOverlay {
//Both of the 428 values stretch the overlay bottom to top for overlay function. It doesn't cover it.
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,428)];
UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,428)];
[FrameImg setImage:[UIImage imageNamed:@"newGraphicOverlay.png"]];
UIToolbar *myToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UIBarButtonItem *myBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(myFunction)];
[myToolBar setItems:[NSArray arrayWithObjects:myBarButtonItem, nil] animated:YES];
[FrameImg addSubview:myToolBar];
[view addSubview:FrameImg];
return view;
}