@Composable
fun CustomClip() {
val customShape = GenericShape { size, _ ->
// 自定义形状: 画一个三角形
moveTo(size.width / 2, 0f)
lineTo(size.width, size.height)
lineTo(0f, size.height)
close()
}
Box(
modifier = Modifier
.size(200.dp)
.clip(customShape) // 使用自定义形状裁剪
.background(Color.Red)
) {
Image(
painter = painterResource(id = R.drawable.aa),
contentDescription = "Custom Clipped Image",
modifier = Modifier.fillMaxSize()
)
}
}
11-28
596
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-23