ios--achieve UIView jitter effect-Similar to password input error effects on Mac

Source: Internet
Author: User

Feel is very good one effect, go to collection.

Direct value call the following method is OK, you need to take it.

#pragma mark Jitter Animation

-(void) Shakeanimationforview: (UIView *) view

{

Gets to the current view

Calayer *viewlayer = View.layer;

Get the current View location

Cgpoint position = viewlayer.position;

Two end locations to move

Cgpoint x = cgpointmake (position.x + ten, POSITION.Y);

Cgpoint y = Cgpointmake (position.x-10, POSITION.Y);

Set animation

Cabasicanimation *animation = [cabasicanimation animationwithkeypath:@ "position"];

Set the form of motion

[Animation settimingfunction:[camediatimingfunction Functionwithname:kcamediatimingfunctiondefault];

Set Start position

[Animation Setfromvalue:[nsvalue valuewithcgpoint:x];

Set End Position

[Animation Settovalue:[nsvalue valuewithcgpoint:y];

Set auto-Invert

[Animation Setautoreverses:yes];

Set the time

[Animation setduration:.06];

Number of settings

[Animation Setrepeatcount:3];

Add on animation

[Viewlayer addanimation:animation Forkey:nil];

ios--achieve UIView jitter effect-Similar to password input error effects on Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.