This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
users:shilo:extensions:sptextfield_justify [2013/07/17 05:34] – shilo | users:shilo:extensions:sptextfield_justify [2013/07/17 05:36] (current) – [Alignment Values] shilo | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== SPTextField+Justify ====== | ||
+ | ---- dataentry extension ---- | ||
+ | type : extension | ||
+ | author_mail | ||
+ | description | ||
+ | lastupdate_dt : 2013-07-16 | ||
+ | compatible | ||
+ | depends | ||
+ | tags : text, textfield, justify, justified, justification | ||
+ | homepage_url | ||
+ | download_url | ||
+ | ---- | ||
+ | ===== Alignment Property Values ===== | ||
+ | |||
+ | <code objc> | ||
+ | #define SPVAlignJustify | ||
+ | |||
+ | #define SPHAlignJustify | ||
+ | #define SPHAlignJustifyLastLineLeft | ||
+ | #define SPHAlignJustifyLastLineCenter SPHAlignJustifyLastLineLeft+1 | ||
+ | #define SPHAlignJustifyLastLineRight | ||
+ | </ | ||
+ | |||
+ | ===== Sample ===== | ||
+ | |||
+ | {{http:// | ||
+ | |||
+ | ===== Usage ===== | ||
+ | |||
+ | <code objc> | ||
+ | // | ||
+ | // Game.m | ||
+ | // AppScaffold | ||
+ | // | ||
+ | |||
+ | #import " | ||
+ | #import " | ||
+ | |||
+ | @implementation Game | ||
+ | |||
+ | - (id)init | ||
+ | { | ||
+ | if ((self = [super init])) | ||
+ | { | ||
+ | Sparrow.stage.color = 0xffffff; | ||
+ | | ||
+ | CGRect screenBounds = [UIScreen mainScreen].bounds; | ||
+ | float stageWidth = screenBounds.size.height; | ||
+ | float stageHeight = screenBounds.size.width; | ||
+ | | ||
+ | NSString *text = @" | ||
+ | | ||
+ | [SPTextField registerBitmapFontFromFile: | ||
+ | | ||
+ | for (SPHAlign hAlign=SPHAlignLeft; | ||
+ | for (SPVAlign vAlign=SPVAlignTop; | ||
+ | NSString *hText = [NSString stringWithFormat: | ||
+ | NSString *vText = [hText stringByAppendingFormat: | ||
+ | | ||
+ | SPTextField *textField = [SPTextField textFieldWithText: | ||
+ | textField.fontName = @" | ||
+ | textField.fontSize = 11; | ||
+ | textField.width = stageWidth/ | ||
+ | textField.height = stageHeight/ | ||
+ | textField.x = hAlign*textField.width; | ||
+ | textField.y = vAlign*textField.height; | ||
+ | textField.hAlign = hAlign; | ||
+ | textField.vAlign = vAlign; | ||
+ | textField.border = YES; | ||
+ | if (vAlign >= SPVAlignJustify || hAlign >= SPHAlignJustify) | ||
+ | textField.color = 0x0000ff; | ||
+ | [self addChild: | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | return self; | ||
+ | } | ||
+ | |||
+ | - (NSString *)hAlignToString: | ||
+ | if (hAlign == SPHAlignLeft) | ||
+ | return @" | ||
+ | else if (hAlign == SPHAlignCenter) | ||
+ | return @" | ||
+ | else if (hAlign == SPHAlignRight) | ||
+ | return @" | ||
+ | else if (hAlign == SPHAlignJustify) | ||
+ | return @" | ||
+ | else if (hAlign == SPHAlignJustifyLastLineLeft) | ||
+ | return @" | ||
+ | else if (hAlign == SPHAlignJustifyLastLineCenter) | ||
+ | return @" | ||
+ | else if (hAlign == SPHAlignJustifyLastLineRight) | ||
+ | return @" | ||
+ | else | ||
+ | return @" | ||
+ | } | ||
+ | |||
+ | - (NSString *)vAlignToString: | ||
+ | if (vAlign == SPVAlignTop) | ||
+ | return @" | ||
+ | else if (vAlign == SPVAlignCenter) | ||
+ | return @" | ||
+ | else if (vAlign == SPVAlignBottom) | ||
+ | return @" | ||
+ | else if (vAlign == SPVAlignJustify) | ||
+ | return @" | ||
+ | else | ||
+ | return @" | ||
+ | } | ||
+ | @end | ||
+ | </ | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * // | ||
+ | |||
+ | ===== Source Code ===== | ||
+ | |||
+ | %gist(6017433)% | ||
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | //No comments so far. Feel free to edit this part of the page.// |