ios - Objective-c: How to add borders to a UIView with auto layout -


how add border specific color , thickness uiview when using auto layout in objective-c ?

this function add border specific color , thickness border of uiview

- (void)addborder:(uiview *)view toedge:(uirectedge)edge withcolor:(uicolor *)color withthickness:(float)thickness{     uiview *border = [uiview new];     border.backgroundcolor = color;     [border setautoresizingmask:uiviewautoresizingflexiblewidth | uiviewautoresizingflexiblebottommargin];     switch (edge) {         case uirectedgetop:             border.frame = cgrectmake(0, 0, view.frame.size.width, thickness);             break;         case uirectedgebottom:             border.frame = cgrectmake(0, view.frame.size.height - thickness, view.frame.size.width, thickness);             break;         case uirectedgeleft:             border.frame = cgrectmake(0, 0, thickness, view.frame.size.height);             break;         case uirectedgeright:             border.frame = cgrectmake(view.frame.size.width - thickness, 0, thickness, view.frame.size.height);             break;         default:             break;     }     [view addsubview:border]; } 

usage

[self addborder:yourview toedge:uirectedgetop withcolor:[uicolor greencolor] withthickness:3.0f]; 

hope make use of all.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -