ios - UIView drawRect issue -


i want make custom uiview border. here code:

- (void)drawrect:(cgrect)rect {     cgcontextref context = uigraphicsgetcurrentcontext();     cgcontextsetlinewidth(context, 4.0);     cgcontextsetstrokecolorwithcolor(context, [[uicolor bluecolor] cgcolor]);     cgcontextaddrect(context, self.frame);     cgcontextstrokepath(context); } 

and here result: enter image description here

all 3 uiview on picture custom view, big uiview have border. don't understand why others have no border. wrong?

you need local coordinates. change

cgcontextaddrect(context, self.frame); 

to

cgcontextaddrect(context, self.bounds); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -