¡@

Home 

2014/10/15 ¤U¤È 10:05:01

iphone Programming Glossary: cgcontextsavegstate

Drawing rotated text with NSString drawInRect

http://stackoverflow.com/questions/10289898/drawing-rotated-text-with-nsstring-drawinrect

since it only sort of works for me https discussions.apple.com thread 1779814 start 0 tstart 0 My code looks like CGContextSaveGState context CGContextDrawLinearGradient context gradient CGPointMake 0 centY halfWidth CGPointMake 0 centY halfWidth 0 Add.. of the context the distance of the height. void drawRect CGRect rect CGContextRef context UIGraphicsGetCurrentContext CGContextSaveGState context CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB Create the gradient CGColorRef startColor UIColor colorWithRed..

How to create a UIImage from the current graphics context?

http://stackoverflow.com/questions/1112947/how-to-create-a-uiimage-from-the-current-graphics-context

Here is what drawRect looks like for me now void drawRect CGRect rect CGContextRef c UIGraphicsGetCurrentContext CGContextSaveGState c CGContextSetStrokeColorWithColor c UIColor blackColor .CGColor CGContextSetLineWidth c 1.5f for CFIndex i 0 i CFArrayGetCount..

How would I tint an image programatically on the iPhone?

http://stackoverflow.com/questions/1117211/how-would-i-tint-an-image-programatically-on-the-iphone

proper blending mode something like this void drawRect CGRect area CGContextRef context UIGraphicsGetCurrentContext CGContextSaveGState context Draw picture first CGContextDrawImage context self.frame self.image.CGImage Blend mode could be any of CGBlendMode..

iPhone - How do you color an image?

http://stackoverflow.com/questions/1223340/iphone-how-do-you-color-an-image

0 0 baseImage.size.width baseImage.size.height CGContextScaleCTM ctx 1 1 CGContextTranslateCTM ctx 0 area.size.height CGContextSaveGState ctx CGContextClipToMask ctx area baseImage.CGImage theColor set CGContextFillRect ctx area CGContextRestoreGState ctx CGContextSetBlendMode..

How do I add a gradient to the text of a UILabel, but not the background?

http://stackoverflow.com/questions/1266179/how-do-i-add-a-gradient-to-the-text-of-a-uilabel-but-not-the-background

and overriding drawRect to have code like the following within it CGContextRef context UIGraphicsGetCurrentContext CGContextSaveGState context CGContextTranslateCTM context 0.0f self.bounds.size.height CGContextScaleCTM context 1.0f 1.0f CGContextSelectFont..

Blur an image of specific part (rectangular, circular)?

http://stackoverflow.com/questions/14107979/blur-an-image-of-specific-part-rectangular-circular

rect.size NO scale CGContextRef context UIGraphicsGetCurrentContext CGContextBeginPath context CGContextSaveGState context CGContextTranslateCTM context CGRectGetMinX rect CGRectGetMinY rect CGContextScaleCTM context radious radious CGFloat..

Rounded Corners on UIImage

http://stackoverflow.com/questions/205431/rounded-corners-on-uiimage

radius radius UIGraphicsBeginImageContext dstRect.size CGContextRef maskedContextRef UIGraphicsGetCurrentContext CGContextSaveGState maskedContextRef CGMutablePathRef borderPath CGPathCreateMutable CGPathAddArc borderPath NULL CGRectGetMinX interiorRect..

Curve text on existing circle

http://stackoverflow.com/questions/3841642/curve-text-on-existing-circle

radius cos degreesToRadians totalRotation float y centerPoint.y radius sin degreesToRadians totalRotation CGContextSaveGState context CGContextTranslateCTM context x y CGContextRotateCTM context degreesToRadians totalRotation 90 CGContextShowTextAtPoint.. charSize.height float x radius cos angle float y radius sin angle float letterAngle charSize.width perimeter 2 M_PI CGContextSaveGState context CGContextTranslateCTM context x y CGContextRotateCTM context angle 0.5 M_PI CGContextShowTextAtPoint context 0 0.. 2 CGContextSetRGBFillColor context textColorComponents 0 textColorComponents 1 textColorComponents 2 textAlpha CGContextSaveGState context CGContextTranslateCTM context centerPoint.x centerPoint.y float angleStep 2 M_PI sections count float angle degreesToRadians..

How to customize the background/border colors of a grouped table view cell?

http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view-cell

rect float ovalWidth float ovalHeight float fw fh if ovalWidth 0 ovalHeight 0 1 CGContextAddRect context rect return CGContextSaveGState context 2 CGContextTranslateCTM context CGRectGetMinX rect 3 CGRectGetMinY rect CGContextScaleCTM context ovalWidth ovalHeight..

how to fit pdf page in entire view

http://stackoverflow.com/questions/4321681/how-to-fit-pdf-page-in-entire-view

pageSize kbDataSource pageSize GLogInfo @ the page ize we are getting in draw layer is @ NSStringFromCGSize pageSize CGContextSaveGState ctx CGSize aspectFitSize self getPageFitSizeOfSize pageSize inSize CGSizeMake self.view.bounds.size.width self.view.bounds.size.height..

Inner shadow effect on UIView layer?

http://stackoverflow.com/questions/4431292/inner-shadow-effect-on-uiview-layer

Now setup the shadow properties on the context aColor UIColor colorWithRed 0.0f green 0.0f blue 0.0f alpha 0.5f CGContextSaveGState context CGContextSetShadowWithColor context CGSizeMake 0.0f 1.0f 3.0f aColor CGColor Now fill the rectangle so the shadow.. context CGSizeMake 0.0f 1.0f 3.0f aColor CGColor Now fill the rectangle so the shadow gets drawn aColor setFill CGContextSaveGState context CGContextAddPath context path CGContextEOFillPath context Release the paths CGPathRelease path CGPathRelease visiblePath..

Draw text in circle overlay

http://stackoverflow.com/questions/7825220/draw-text-in-circle-overlay

super drawMapRect mapRect zoomScale zoomScale inContext context NSString t @ XXXXX nXXXX UIGraphicsPushContext context CGContextSaveGState context UIColor redColor set CGRect overallCGRect self rectForMapRect self.overlay boundingMapRect NSLog @ MKC lf lf lf..

How do I draw a shadow under a UIView?

http://stackoverflow.com/questions/805872/how-do-i-draw-a-shadow-under-a-uiview

the following in a UIView subclass void drawRect CGRect rect CGContextRef currentContext UIGraphicsGetCurrentContext CGContextSaveGState currentContext CGContextSetShadow currentContext CGSizeMake 15 20 5 CGContextRestoreGState currentContext super drawRect.. if you rearrange your code like this void drawRect CGRect rect CGContextRef currentContext UIGraphicsGetCurrentContext CGContextSaveGState currentContext CGContextSetShadow currentContext CGSizeMake 15 20 5 super drawRect rect CGContextRestoreGState currentContext..

How to mask a square image into an image with round corners in the iPhone SDK?

http://stackoverflow.com/questions/996292/how-to-mask-a-square-image-into-an-image-with-round-corners-in-the-iphone-sdk

rect float ovalWidth float ovalHeight float fw fh if ovalWidth 0 ovalHeight 0 CGContextAddRect context rect return CGContextSaveGState context CGContextTranslateCTM context CGRectGetMinX rect CGRectGetMinY rect CGContextScaleCTM context ovalWidth ovalHeight.. example assuming image is a UIImage and this is in a drawRect method CGContextRef context UIGraphicsGetCurrentContext CGContextSaveGState context addRoundedRectToPath context self.frame 10 10 CGContextClip context image drawInRect self.frame CGContextRestoreGState..