在我的資源下載Libqrencode 這個庫 然後導入庫
//二維碼圖片
if (!_qRImg) {
_qRImg = [[DLImageView alloc] initWithFrame:CGRectMake(30, YHeight(_avatar) + 20, self.frame.size.width - 60, self.frame.size.width - 60)];
_qRImg.userInteractionEnabled = YES;
// _qRImg.backgroundColor = [UIColor grayColor];
// self.qRImg.delegate = self;
[self addSubview:self.qRImg];
}
UIImage *image = [QRCodeGenerator qrImageForString:[NSString stringWithFormat:@"http://www.baidu.com"] imageSize:_qRImg.frame.size.width];
[_qRImg setImage:image];