Thursday, February 21, 2019

Make blinking point

We want to make a small red blinking point to attract user attention.
Copy these lines in to viewDidLoad
var ar = [UIImage]()
        let w : CGFloat = 18
        for i in 0 ..< 6 {
            UIGraphicsBeginImageContextWithOptions(CGSizeMake(w,w), false, 0)
            let con = UIGraphicsGetCurrentContext()
            CGContextSetFillColorWithColor(con, UIColor.redColor().CGColor)
            let ii = CGFloat(i)
            CGContextAddEllipseInRect(con, CGRectMake(0+ii,0+ii,w-ii*2,w-ii*2))
            CGContextFillPath(con)
            let im = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()
            ar += [im]
        }
        let im = UIImage.animatedImageWithImages(ar, duration:0.5)
        button.setImage(im, forState:.Normal)
Blinking point will show nearby button.


If don’t want to see button, let set button background to white, so we see only red point.

No comments:

Post a Comment