重生之yy天下txt,搜才人才网,果帅帅娱乐网
ios 系统框架已经给我们提供了相应的切割圆角的方法, 但是如果在一个见面有很多控件切割的话会出现卡顿和个别不切得现在
/* 创建一个button */ uibutton * button = [uibutton buttonwithtype:(uibuttontypesystem)]; [button setframe:cgrectmake(100, 100, 100, 100)]; [self addsubview:button]; /* 正厂的圆角需求处理方法 */ button.layer.cornerradius = 10.0f; //弧度 button.layer.maskstobounds = yes; /* 贝塞尔曲线切割 */ /** * * @param uirectcorner * 左上 uirectcornertopleft = 1 << 0, 左下 uirectcornerbottomleft = 1 << 2, 右下 uirectcornerbottomright = 1 << 3, 所有角 uirectcornerallcorners = ~0ul * */ uibezierpath *maskpath = [uibezierpath bezierpathwithroundedrect:button.bounds byroundingcorners:uirectcornertopleft | uirectcornerbottomleft cornerradii:button.bounds.size]; cashapelayer *masklayer = [[cashapelayer alloc]init]; //设置大小 masklayer.frame = button.bounds; //设置图形样子 masklayer.path = maskpath.cgpath; button.layer.mask = masklayer;
注意: 如果这里选择两个角 的话如果是选两个对角线 则会切 所有角
比如:uirectcornertopleft | uirectcornerbottomright 他就会切割所有角
当然你也可以直接创建个圆角的button
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
iOS 使用UITextField自定义搜索框 实现用户输入完之后“实时搜索”功能
网友评论