¡@

Home 

2014/10/15 ¤U¤È 10:04:10

iphone Programming Glossary: attrstring

how to make bold font NSString value?

http://stackoverflow.com/questions/11648432/how-to-make-bold-font-nsstring-value

yourString NSString stringWithFormat @ @ @ @ key @ @ NSRange boldedRange NSMakeRange 22 4 NSMutableAttributedString attrString NSMutableAttributedString alloc initWithString yourString attrString beginEditing attrString addAttribute kCIAttributeName.. NSMakeRange 22 4 NSMutableAttributedString attrString NSMutableAttributedString alloc initWithString yourString attrString beginEditing attrString addAttribute kCIAttributeName value boldFontName range boldedRange attrString endEditing NSString.. attrString NSMutableAttributedString alloc initWithString yourString attrString beginEditing attrString addAttribute kCIAttributeName value boldFontName range boldedRange attrString endEditing NSString string NSString stringWithFormat..

Two colors for UILabel TEXT

http://stackoverflow.com/questions/13579209/two-colors-for-uilabel-text

test @ Hello. That is a test attributed string. CFStringRef string CFStringRef test CFMutableAttributedStringRef attrString CFAttributedStringCreateMutable kCFAllocatorDefault 0 CFAttributedStringReplaceString attrString CFRangeMake 0 0 string.. attrString CFAttributedStringCreateMutable kCFAllocatorDefault 0 CFAttributedStringReplaceString attrString CFRangeMake 0 0 string Note we could have created CFAttributedStringRef which is non mutable then we would have to give.. 20 letters as orange next 20 letters as green next 20 as red last remaining as blue CFAttributedStringSetAttribute attrString CFRangeMake 0 20 kCTForegroundColorAttributeName _orange CFAttributedStringSetAttribute attrString CFRangeMake 20 20 kCTForegroundColorAttributeName..

Core Text: Render to an Odd Shape

http://stackoverflow.com/questions/3813318/core-text-render-to-an-odd-shape

cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum. CFMutableAttributedStringRef attrString CFAttributedStringCreateMutable kCFAllocatorDefault 0 CFAttributedStringReplaceString attrString CFRangeMake 0 0 string.. attrString CFAttributedStringCreateMutable kCFAllocatorDefault 0 CFAttributedStringReplaceString attrString CFRangeMake 0 0 string Create the framesetter with the attributed string. CTFramesetterRef framesetter CTFramesetterCreateWithAttributedString.. the framesetter with the attributed string. CTFramesetterRef framesetter CTFramesetterCreateWithAttributedString attrString CFRelease attrString Create the frame and draw it into the graphics context CTFrameRef frame CTFramesetterCreateFrame framesetter..

Get truncated text from UILabel

http://stackoverflow.com/questions/6728259/get-truncated-text-from-uilabel

attr NSDictionary dictionaryWithObject id ctFont forKey id kCTFontAttributeName CFRelease ctfont NSAttributedString attrString NSAttributedString alloc initWithString yourLabelText attributes attr CTFrameSetterRef frameSetter CTFrameSetterCreateWithAttributedString.. attributes attr CTFrameSetterRef frameSetter CTFrameSetterCreateWithAttributedString CFAttributedStringRef attrString attrString release CFRange fitRange CTFrameSetterSuggestFrameSizeWithConstrains frameSetter CFRangeMake 0 0 NULL CGSizeMake.. attributes attr CTFrameSetterRef frameSetter CTFrameSetterCreateWithAttributedString CFAttributedStringRef attrString attrString release CFRange fitRange CTFrameSetterSuggestFrameSizeWithConstrains frameSetter CFRangeMake 0 0 NULL CGSizeMake labelWidth..