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 stringNSString* myString = @"Some text";// create a dictionaryNSMutableDictionary *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 alignmentNSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];paragraphStyle.alignment = NSTextAlignmentRight;// create an NSAttributedString and add text properties to itNSAttributedString *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 appliedexcept the alignment, this is not working.What am I doing wrong here?Can someone help me further?
Post
Replies
Boosts
Views
Activity
Hello,
Objective-C
Calling a function from class A which is located in class B,
within function B I try to pick up some stringValue from multiple NSTextFields (['NSTextField' stringValue]).
The result is always NULL, why?
When the class B function is called directly from within the class B by a button action for example, I can get the stringValue perfectly.
How can I implement a NSProgressIndicator in a non void function?
This is not supported in a non void function, what can I do?
dispatchasync( dispatchgetglobalqueue(DISPATCHQUEUEPRIORITYDEFAULT, 0),
dispatchasync(dispatchgetmain_queue(), ^{
[myProgressBar setUsesThreadedAnimation:YES];
[myProgressBar setHidden:FALSE];
[myProgressBar setDoubleValue:15.0];
[myProgressBar startAnimation:myProgressBar];
});
});
any help is very appreciated.
I'm working on an objective c based macos project for years, containing numerous Objective C classes.
For some reason, in a particular class I can bind new IBOutlets in Interface builder, but in my .m file I get always the error:
Use of undeclared identifier ' my buttoname '
Someone any idea?
I'm working with:
XCode 13.2.1