I'm using CoreText
and I want to make it so my NSMutableAttributedString
always center aligns its text. This is the code I'm using and it isn't working:
CTTextAlignment paragraphAlignment = kCTCenterTextAlignment;
CTParagraphStyleSetting paragraphSettings[1] = {{kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), ¶graphAlignment}};
CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(paragraphSettings, 1);
text = [[NSMutableAttributedString alloc] initWithString:@"" attributes:[NSDictionary dictionaryWithObjectsAndKeys: (id)paragraphStyle, (NSString*)kCTParagraphStyleAttributeName, nil]];
Does anyone have any idea how to do this correctly?