iOS 画图 和 android 画图对比

2 篇文章 0 订阅

        

       简单总结做个笔记,接触iOS本身也没多长时间,最近又跟android干上了,哈哈,遇到点问题对比记记,方便以后及时查看吧。之后会总觉下iOS的粒子动画效果,总算弄通了哦。粒子效果很酷。iOS的动画开发比android要简单好多哦。iOS不用CAShapLayer UIBeziearPath,就用纯画布绘制。

      UIImage 和 Bitmap 很像。我在andriod和iOS 都画一个椭圆,画笔的设置其实都一样。

       iOS:        

     UIGraphicsBeginImageContextWithOptions(CGSizeMake(10, 10), NO, 0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextAddEllipseInRect(context, CGRectMake(0, 0, 10, 10));
    CGContextSetLineWidth(context, 6);
    CGContextSetLineCap(context,kCGLineCapRound);
    //CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor);
    CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
    //CGContextFillPath(context);
    CGContextStrokePath(context);
    UIImage* image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

   贴一个UIImageContext方法:

UIKIT_EXTERN void     UIGraphicsBeginImageContext(CGSize size);
UIKIT_EXTERN void     UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale) NS_AVAILABLE_IOS(4_0);
UIKIT_EXTERN UIImage* UIGraphicsGetImageFromCurrentImageContext(void);
UIKIT_EXTERN void     UIGraphicsEndImageContext(void); 

android android的可以继承一个View或SurfaceView来进行绘制,也可以不用,事先准备好一个bitmap就行了

Paint mPaint = new Paint();

mPaint.setStrokeCap(Cap. ROUND );

mPaint.setAntiAlias( true );

mPaint.setColor(Color. BLACK );

mPaint.setStrokeWidth(3);

Bitmap mBitmap = Bitmap.createBitmap(40, 40, Config. ARGB_8888 );

Canvas mCanvas = new Canvas(mBitmap);

Rect mRect = new Rect(0, 0, 10, 10);

RectF mRectF = new RectF(mRect);

mCanvas.drawOval(mRectF, mPaint);

ImageView imageView = new ImageView( this );
imageView.setImageBitmap(mBitmap);

感觉手工画图程序极为相似,iOS使用的C语言的形式,android是Java包装过的。上面的程序很简单,我只是做个对比备忘,防止自己在两个平台交叉给忘记咯。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值