在ZBar扫描仪顶部添加叠加层
我正在使用ZBar SDK读取iPhone上的QR码,但是我想添加一些文字到相机/扫描仪视图的底部,这是用户的教学文本。 这是我到目前为止:
UIView *cameraOverlayView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; cameraOverlayView.backgroundColor = [UIColor redColor]; UILabel *instructionLabel = [[UILabel alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; [instructionLabel setTextColor:[UIColor grayColor]]; [instructionLabel setBackgroundColor:[UIColor clearColor]]; [instructionLabel setFont:[UIFont fontWithName: @"Trebuchet MS" size: 24.0f]]; [instructionLabel setCenter:cameraOverlayView.center]; [cameraOverlayView addSubview:instructionLabel]; reader.cameraOverlayView = cameraOverlayView; reader.wantsFullScreenLayout = YES; [instructionLabel release]; [cameraOverlayView release];
这是完整的课程:
https://gist.github.com/4163761
不幸的是,标签不显示。 ZBar的文件说为了这个目的使用cameraOverlayView,但它似乎并没有工作。
另外需要注意的是,我正在使用Titanium框架,所以这是额外的Titanium类的来源,但我的问题应该是特定于ZBar。
你有没有看到cameraOverlayView? 设置背景颜色为红色或其他:cameraOverlayView.backgroundColor = [UIColor redColor];
如果您根本没有看到cameraOverlayView,那么您可能需要设置阅读器。 showsZBarControls = NO将禁用默认控件并使用您的自定义覆盖。
如果你看到cameraOverlayView,那么标签可能在界限之外。 玩弄原点,并把它放到位置。
顺便说一句我看你不使用ARC,请确保你释放instructionLabel!
- CAShapeLayer的框架和边界
- 从UIPastboard粘贴字符串数据
- iOS 7替代CTCall?
- xcode 7.1 swift框架应用程序构build但不归档
- 预加载核心数据库UIManagedDocument黑色
- 为什么我得到一个SQLITE_MISUSE:内存不足错误?
- cordova应用程序挂起在iOS 10上启动
- AFURLConnectionOperation.m隐式转换失去整数精度:'int64_t'(又名'long long')到'NSInteger'(又名'int')
- 添加一个正确的“完成”button(UIBarButtonItem)到UINavigationController