The effect of _ios on the implementation of dynamic elements in IOS

Source: Internet
Author: User

Objective

Recently more and more apps, has abandoned the first entry into the 3-4 page of the Import page, but also took the function page to suspend a dynamic effect to show the corresponding function points. This module is mainly to achieve the first time app to display the dynamic guide, when the user to the right or left-sliding, some elements on the screen to make the corresponding hidden disappear and position movement.

Implementation effect:


Image resources from the network, infringement is deleted

Let's take a look at how it is used and then introduce the relevant methods and properties

Nsmutablearray * Elementsdataarr = [[Nsmutablearray alloc] init]; /* Animation element creation/lmjanimatedelement * element1 = [[Lmjanimatedelement alloc] initwithimage:[uiimage imagenamed:@ "Umbrella"]
];      Element1.belongtoscreen = 0; Set the number of screen element1.size = Cgsizemake (64, 64); Element size Element1.startpoint = Cgpointmake (130, 420); Element at the starting point of the screen element1.endpoint = Cgpointmake (130, 420);     The element element1.isgradient = NO at the end of the screen;

Whether to fade in [Elementsdataarr addobject:element1];
Lmjanimatedelement * Element2 = [[Lmjanimatedelement alloc] initwithimage:[uiimage imagenamed:@ "cocktail"]];
Element2.belongtoscreen = 1;
Element2.size = Cgsizemake (64, 64);
Element2.startpoint = Cgpointmake (40, 350);
Element2.endpoint = Cgpointmake (40, 480);
Element2.isgradient = YES;

[Elementsdataarr Addobject:element2];
Lmjanimatedelement * Element3 = [[Lmjanimatedelement alloc] initwithimage:[uiimage imagenamed:@ "Flip_flops"]];
Element3.belongtoscreen = 2;
Element3.size = Cgsizemake (64, 64); ElemeNt3.startpoint = Cgpointmake (-70, 500);
Element3.endpoint = Cgpointmake (190, 470);
Element3.isgradient = YES;

[Elementsdataarr Addobject:element3];
Lmjanimatedelement * Element4 = [[Lmjanimatedelement alloc] initwithimage:[uiimage imagenamed:@ "surfboard"]];
Element4.belongtoscreen = 3;
Element4.size = Cgsizemake (96, 96);
Element4.startpoint = Cgpointmake (300, 440);
Element4.endpoint = Cgpointmake (40, 440);
Element4.isgradient = NO;

[Elementsdataarr ADDOBJECT:ELEMENT4];
Lmjanimatedelement * element5 = [[Lmjanimatedelement alloc] initwithimage:[uiimage imagenamed:@ "Beach_chair"]];
Element5.belongtoscreen = 4;
Element5.size = Cgsizemake (64, 64);
Element5.startpoint = Cgpointmake (320, 440);
Element5.endpoint = Cgpointmake (220, 440);
Element5.isgradient = YES;

[Elementsdataarr ADDOBJECT:ELEMENT5]; /* Module Implementation * * _welcomeview = [[Lmjdynamicwelcomeview alloc] Initwithframe:cgrectmake (0, 0, [UIScreen mainscreen].
Bounds.size.height, [UIScreen mainscreen].bounds.size.height)];Set animation elements [_welcomeview Setanimateditems:elementsdataarr]; Set the background picture, as well as the size of the background picture, when the picture size exceeds the screen width, will automatically calculate the background image of each screen displacement, so that when the last screen slide, the background image moved to the right end [_welcomeview setbackgroundimage:[uiimage imagenamed:@ "Beach_bg.png"] Size:cgsizemake (_WELCOMEVIEW.FRAME.SIZE.HEIGHT/620.F*992.F, _
WelcomeView.frame.size.height)];

Set the slide screen number [_welcomeview setanimatedpagecount:5]; [Self.view Addsubview:_welcomeview];

First look at the element class, which is the element that moves on the guide map (lmjanimatedelement)

-(Lmjanimatedelement *) Initwithimage: (UIImage *) image;

-(Lmjanimatedelement *) Initwithtext: (NSString *) text; This feature is not yet implemented, please look forward to ...

@property (nonatomic,assign) Nsinteger Belongtoscreen; The number of screen (value range: 0~ ...)

@property (nonatomic,assign) cgsize size;//Element size

@property (nonatomic,assign) cgpoint startpoint;//Animation starting point
@property (nonatomic,assign) cgpoint endPoint;//Animation endpoint

@property (nonatomic,assign) BOOL isgradient;//Whether there is a gradient effect When set to Yes, the animation element only appears on the page following the animation, and when set to No, the animation element is displayed on the screen, only on the page to which it belongs

@property (nonatomic,strong) UIView * Elementview; Element container

Let's take a look at the method of the module (Lmjdynamicwelcomeview)

/* Set all animation elements * *
-(void) Setanimateditems: (nsarray<lmjanimatedelement *> *) items;

/* Set the number of screens to slide the guide chart */
(void) Setanimatedpagecount: (Nsinteger) count;

/* Set background and background image size * *
(void) SetBackgroundImage: (UIImage *) image size: (cgsize) size;

Summarize

The above is the full content of this article, I hope that the iOS developers can help, if you have questions you can message exchange.

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.