Managing views while integrating zxing for iPhone

旧城冷巷雨未停 提交于 2019-12-03 21:38:35

With ZXing you can access the overlay view directly and add/change its subviews. For example, putting an imageview on top of this overview is done as follows:

ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];

UIImage *qrOverlayImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"overlay-image" ofType:@"png"]];

UIImageView *qrOverlayImageView = [[[UIImageView alloc] initWithImage:qrOverlayImage] autorelease];
qrOverlayImageView.contentMode = UIViewContentModeScaleAspectFit;
qrOverlayImageView.backgroundColor = [UIColor clearColor];

[widController.overlayView addSubview:qrOverlayImageView];

Use PNGs with transparency, add UILabels etc to create your custom overlay programmatically.

Just a small note to consider; on testing Mountain Lion with Xcode 4.4 I couldn't get one of my existing projects to compile because of ZBar. I can't say whether ZBar will be updated to work with Xcode 4.4 or whether something will change in Xcode 4.4 that will enable ZBar to work. Who knows!

I've updated my projects to use Zxing instead even though it is harder to get working and to configure it.

Update: I've started using ZXingObjC now (https://github.com/TheLevelUp/ZXingObjC). It's easier to get working than Zxing and it's also got a lot of the features that are missing in Zxing in it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!