I want to dynamically change the current CGContextRef according to different user actions? Is this possible or is its modification only possible within drawRect: of a view instance? What happens when I call UIGraphicsGetCurrentContext() outside drawRect: and are there any limitations in doing so, is this recommended? Any possible implications I need to consider?
iOS - Can UIGraphicsGetCurrentContext be used outside drawRect?
719 Views Asked by nburk At
1
There are 1 best solutions below
Related Questions in IOS
- Overlapping UICollectionView in storyboard
- Cannot pod spec lint because of undeclared type errors
- Is the transactionReceipt data present in dataWithContentsOfURL?
- UIWebView Screen Fitting Issue
- ZXingObjC encoding issues
- iOS: None of the valid provisioning profiles allowed the specific entitlements
- How to hide "Now playing url" in control center
- CloudKit: Preventing Duplicate Records
- Slow performance on ipad erasing image
- Swift code with multiple NSDateFormatter - optimization
- iOS 8.3 Safari crashes on input type=file
- TTTTimeIntervalFormatter always returns strings in English
- How do I add multiple in app purchases in Swift Spritekit?
- Setup code for xibs in iOS. -awakFromNb:
- iOS Voice Over only reads out the title of any alert views
Related Questions in CORE-GRAPHICS
- Drawing in UIView on touch points gives blurr drawing effect on boundaries
- Resolution Loss when generating an Image from UIImageView
- Draw/Paint like sketch color inside a bezier path in UIView
- Best performant way to check if an image is all white?
- How can I animate some subviews of a UIViewController "off" the screen, and other views "on" the screen?
- How to draw an arrow inside a disk?
- How can I set the UINavigationbar with gradient color?
- How to get displayID of display application currently displayed on?
- How to cut the shape of a logo(png image) from another image programmatically in Swift?
- UIGraphicsGetImageFromCurrentImageContext crash when using a queue
- Change CGSize with a variable
- Add a semi-transparent layer to UIImage using Core Graphics
- CGDisplayCopyAllDisplayModes leaves out one valid mode
- Gradient defined by trigonometric function in core graphics
- How does CALayer geometryFlipped behave exactly?
Related Questions in CGCONTEXT
- Multiple CGContextRefs?
- Apply orientation to CGContext
- How to draw a line between two points over an image in swift 3?
- Get real frame after affine transformation
- Adding text to a CGContext with Swift
- Draw Radial Gradient iOS top half area of a UIView
- CALayer drawrect Anti-Aliasing didn't worked
- Using CGRect and CGContext to Create ImageView for Signature Box
- Core Graphics: CGContextClip() Edge Unwanted Weird Antialiasing
- Core Graphics drawings incorrectly scaled and translated in device but okay in Interface Builder
- Qt 5.3.2 / OSX cannot use native CGContext drawing in paintEvent / Flickering
- CGBitmapContextCreate gives EXC_BAD_ACCESS in iPhone 6+
- How to stroke the dotted lines using cgcontext iOS?
- Text rotation issue in CGContext
- erase drawing that is saved to another image view Xcode
Related Questions in CGCONTEXTREF
- CGContextRef inset?
- ios 7 NSString drawInRect using CoreGraphics
- Find out if CGContext contains a specific Area - iPhone
- iOS - Invalid context on CGContextRotateCTM
- How save CGContextRef as .PNG file?
- How to store CGContext state in a NSMutableArray?
- UIGraphicsBeginImageContext wasteful?
- CGContextFillPath(context) gets removed when creating a line
- CTRunDraw() does implement correct behaviour
- On iOS, is doing CGContextRelease required?
- CGContextRef as OpenGL Context
- Separating multiple UILabels with a line IOS
- iOS - Can UIGraphicsGetCurrentContext be used outside drawRect?
- Different behaviours for different colors in drawRect:
- iOS9 Heap Buffer Overflow Detected - CGContextSetFillColor
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
According to the docs the graphics context is only set just before this function is called. This means that if this function is not called it won't be set and if you don't make the system call it again (never do this yourself for that reason) it won't be there either.
Use one of these functions to force the view back into drawRect:
It doesn't mean you can only do stuff inside drawRect however. This context is sort of globally available at that moment and you can call clean separate functions or even classes for drawing things. Passing the reference to those functions is a clean way to do it.