Android端图像圆角处理但iOS端不处理的问题
创始人
2024-10-07 14:34:50
0

在Android端,可以通过将图片转换为圆形或圆角矩形来实现:

public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float roundPx) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}

在iOS端,需要对UIImageView进行圆角处理:

imageView.layer.cornerRadius = imageView.frame.size.width / 2;
imageView.clipsToBounds = true;

这样就可以在两个平台上都进行圆角处理啦。

相关内容

热门资讯

推荐十款!wepoker私人局... 您好,wepoker私人局辅助挂这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】...
玩家必看秘籍!hhpoker是... 玩家必看秘籍!hhpoker是内部控制吗,wepoker透视最简单三个步骤,黑科技教程(有挂技巧);...
发现一款!wepoker智能辅... 1、发现一款!wepoker智能辅助插件,wepoker辅助透视,扑克教程(有挂攻略)2、进入游戏-...
分享开挂内幕!aapoker如... 分享开挂内幕!aapoker如何设置胜率,wpk俱乐部辅助器,技巧教程(有挂软件)是由北京得aapo...
推荐十款!哈糖大菠萝怎么开挂,... 推荐十款!哈糖大菠萝怎么开挂,sohoopoker辅助,必备教程(有挂神器)科技教程也叫必备教程,这...
一分钟揭秘!德州透视插件,hh... 一分钟揭秘!德州透视插件,hhpoker一直输有挂吗,黑科技教程(有挂方法)是一款可以让一直输的玩家...
实测揭晓!wepoker安装教... 实测揭晓!wepoker安装教程,德州辅助工具到底怎么样,攻略方法(有挂辅助)准备好在德州辅助工具到...
重大推荐!pokemmo辅助脚... 重大推荐!pokemmo辅助脚本,pokemmo脚本辅助器下载,我来教教你(有挂辅助)1、许多玩家不...
最新通报!cloudpoker... 最新通报!cloudpoker怎么开挂,wpk透视辅助,新版2025教程(有挂攻略);《WPK辅助透...
玩家必备教程!wepoker数... 玩家必备教程!wepoker数据分析,wepoker辅助器下载,德州教程(有挂透明);1分钟了解详细...