basic question, but I'm unsure. Not looking for code as an answer.
I want to draw 4 short lines 1px lines on a view. What is the best way to approach this task? Options:-
- Load an image of the line, then create 4 UIImageViews with it.
- Create my own subclass of a UIView that d开发者_StackOverflow社区raws a line in the draw rect method.
- Draw elsewhere on another view, another UIImageView that has an UIImage inside it (is this possible?)
- Another way?
Thanks Ross
Simplest way is to create a UIView
subclass and perform your drawing in drawRect:
. See the CoreGraphics guide for details on how to draw a line.
Quick and dirty way to achieve this is to just create a UIView and set it's height (or width, depending on its orientation) to 1px, and then set a background colour and slap it onto your view as a subview.
精彩评论