Xamarin Ios-仅在一侧创建圆形按钮 [英] Xamarin Ios - Create rounded buttons on only 1 side

查看:81
本文介绍了Xamarin Ios-仅在一侧创建圆形按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为Xamarin Ios开发一个应用程序,我正在努力寻找一种方法来将圆形边框仅应用到UIButton类型的按钮的一侧.

I'm currently developing an App for Xamarin Ios and i'm struggling to find a way to apply a rounded border to simply one side off a button of a UIButton type.

推荐答案

在UIButton子类中,重写LayoutSubviews方法并添加掩码:

In your UIButton subclass, override the LayoutSubviews method and add a mask:

public override void LayoutSubviews()
{
    var maskingShapeLayer = new CAShapeLayer()
    {
        Path = UIBezierPath.FromRoundedRect(Bounds, UIRectCorner.BottomLeft | UIRectCorner.TopLeft, new CGSize(20, 20)).CGPath
    };
    Layer.Mask = maskingShapeLayer;
    base.LayoutSubviews();
}

这篇关于Xamarin Ios-仅在一侧创建圆形按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆