2

I am doing subclassing of UIView, how do I do Left and Right text justification using CGContextShowTextAtPoint? thx

1 Answer 1

4

First of all you need to measure your text using one of [NSString sizeWithFont...] methods. You'll get size Use it's width to place your text in the right point:

pseudocode:

if (justification == Left) {
    //just use CGContextShowTextAtPoint
} else {
    CGSize size = [text sizeWithFont:....];
    CGContextShowTextAtPoint(context, self.bounds.width - size.width,....);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.