大佬教程收集整理的这篇文章主要介绍了ios – 相机打开时如何绘制网格线avcapturemanager,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这就是我在我的应用程序Subvision中做到的方式:
我用来绘制它的代码(注意:我的网格是可调整的,所以它可以是10×10,2×2等):
// ------------------------------------------------------------------------------- // Used for drawing the grids ontop of the view port // ------------------------------------------------------------------------------- - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context,0.5); CGContextSetstrokeColorWithColor(context,[UIColor whiteColor].CGColor); // --------------------------- // Drawing column lines // --------------------------- // calculate column width CGFloat columnWidth = self.frame.size.width / (self.numberOfcolumns + 1.0); for(int i = 1; i <= self.numberOfcolumns; i++) { CGPoint startPoint; CGPoint endPoint; startPoint.x = columnWidth * i; startPoint.y = 0.0f; endPoint.x = startPoint.x; endPoint.y = self.frame.size.height; CGContextMoveToPoint(context,startPoint.x,startPoint.y); CGContextAddLineToPoint(context,endPoint.x,endPoint.y); CGContextstrokePath(context); } // --------------------------- // Drawing row lines // --------------------------- // calclulate row height CGFloat rowHeight = self.frame.size.height / (self.numberOfRows + 1.0); for(int j = 1; j <= self.numberOfRows; j++) { CGPoint startPoint; CGPoint endPoint; startPoint.x = 0.0f; startPoint.y = rowHeight * j; endPoint.x = self.frame.size.width; endPoint.y = startPoint.y; CGContextMoveToPoint(context,endPoint.y); CGContextstrokePath(context); } }
在我的GridView类中,我定义了2个属性numberOfRows和numberOfcolumns:
#import <UIKit/UIKit.h> @interface GridView : UIView @property (nonatomic,assign) int numberOfcolumns; @property (nonatomic,assign) int numberOfRows; @end
这样做意味着我可以修改这两个值并具有无限可调的网格细分.
以上是大佬教程为你收集整理的ios – 相机打开时如何绘制网格线avcapturemanager全部内容,希望文章能够帮你解决ios – 相机打开时如何绘制网格线avcapturemanager所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。