Undo/Redo for drawing in iOS

I have found a solution for this, we need to create a array of array of DrawingPaths: – (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // Do the above code, then [m_undoArray addObject:self.currentPath]; } – (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [m_parentUndoArray addObject:[NSArray arrayWithArray:m_undoArray]]; } and then stroke the path in DrawRect.

Union UIBezierPaths rather than apend path

You can get desired result easily by following 2 concepts of Core Graphics :- i)CGBlendMode ii)OverLap2Layer Blend modes tell a context how to apply new content to itself. They determine how pixel data is digitally blended. class UnionUIBezierPaths : UIView { var firstBeizerPath:UIImage! var secondBeizerPath:UIImage! override func draw(_ rect: CGRect) { super.draw(rect) firstBeizerPath = drawOverLapPath(firstBeizerpath: … Read more

Fade out scrolling UITextView over image?

Oh man, I use this a lot. Have it saved as a snippet: CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = self.textView.superview.bounds; gradient.colors = @[(id)[UIColor clearColor].CGColor, (id)[UIColor blackColor].CGColor, (id)[UIColor blackColor].CGColor, (id)[UIColor clearColor].CGColor]; gradient.locations = @[@0.0, @0.03, @0.97, @1.0]; self.textView.superview.layer.mask = gradient; This solution requires that your text view be embedded in a view of its own. … Read more

How can I set the UINavigationbar with gradient color?

Details Xcode 11.4 (11E146), swift 5 Tested on iOS 13.1, 12.2, 11.0.1 Solution class UINavigationBarGradientView: UIView { enum Point { case topRight, topLeft case bottomRight, bottomLeft case custom(point: CGPoint) var point: CGPoint { switch self { case .topRight: return CGPoint(x: 1, y: 0) case .topLeft: return CGPoint(x: 0, y: 0) case .bottomRight: return CGPoint(x: 1, … Read more

iOS 7 style Blur view

You might be able to modify something like Bin Zhang’s RWBlurPopover to do this. That component uses my GPUImage to apply a Gaussian blur to components underneath it, but you could just as easily use a CIGaussianBlur for the same. GPUImage might be a hair faster though. That component relies on you being able to … Read more