Hi all,
I have problems with text alignment.
I like to right align some text on an image.
My code looks like this:
// my text string
NSString* myString = @"Some text";
// create a dictionary
NSMutableDictionary *userAttributes = [[NSMutableDictionary alloc] init];
// fill my dictionary with text properties
[userAttributes setObject:[NSFont fontWithName:mySelectedFont size:myFontSize] forKey:NSFontAttributeName];
[userAttributes setObject:myFontColor forKey:NSForegroundColorAttributeName];
// create a paragraph style to define my text alignment
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = NSTextAlignmentRight;
// create an NSAttributedString and add text properties to it
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:myString attributes:userAttributes];
// draw the "attributed string" at a given point
[attrString drawAtPoint:NSMakePoint(myXTLval,myYTLval)];
The text is placed exactly where I want it,
the font is applied
except the alignment, this is not working.
What am I doing wrong here?
Can someone help me further?