Pregunta

In interface builder, we can simply drag a line to the view.

But I want to programmatically assign a line (for example, vertical line) into my view hierarchy, what should I initialize the box before - addSubview: and - setFrame: methods?

¿Fue útil?

Solución

Sorry, I solve it myself. Here are the codes:

NSBox *line = [[NSBox alloc] init];
[line setBoxType:NSBoxSeparator];                     /* make it a line */
[line setFrame:NSMakeRect(0.0, 20.0, 300.0, 0.0)];    /* Or assign NSLayoutConstraint objects */
[self.view addSubview:line];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top