iOS View新增虛線邊框

2021-07-16 01:37:11 字數 843 閱讀 9035

borderlayer.bounds設定為比view小一點,虛線比較明顯

borderlayer.linedashpattern的屬性設定不同大小能修改虛線每一小段的長度

把cell.backview替換為對應的view就可以了

cashapelayer *borderlayer = [cashapelayer layer];

borderlayer.bounds = cgrectmake(1, 1, screenwidth-34, 48);

borderlayer.position = cgpointmake(cgrectgetmidx(cell.backview.bounds), cgrectgetmidy(cell.backview.bounds));

borderlayer.path = [uibezierpath bezierpathwithroundedrect:borderlayer.bounds cornerradius:3].cgpath;

borderlayer.linewidth = 1;

//虛線邊框

borderlayer.linedashpattern = @[@4, @4];

//實線邊框

//    borderlayer.linedashpattern = nil;

borderlayer.fillcolor = [uicolor clearcolor].cgcolor;

borderlayer.strokecolor = [uicolor graycolor].cgcolor;

[cell.backview.layer addsublayer:borderlayer];

iOS為UIView新增虛線邊框

有時候需要為uiview新增虛線描邊,本文記錄一種實現方式,主要是通過對uiview的根layer新增cashapelayer來完成。效果圖如下 cgsize screensize uiscreen mainscreen bounds.size cgfloat viewwidth 200 cgflo...

iOS view新增陰影

四邊陰影 uiview view uiview new view.layer.shadowcolor uicolor lightgraycolor cgcolor view.layer.shadowoffset cgsizemake 0,0.5 view.layer.shadowopacity 0....

CSS border虛線邊框屬性教程

上下左右邊框交界處呈現平滑的斜線。利用這個特點,通過設定不同的上下左右邊框寬度或顏色,可以得到小三角 梯形等。調整寬度大小可以調節三角形形狀。實現三角形 示例1 css code複製內容到剪貼簿 示例2 在上面的基礎上,把高度寬度都設為0時,會呈現邊界斜線。css code複製內容到剪貼簿 示例3 ...