IOS: A Multi-choice control with animation (2); ios animation control

Source: Internet
Author: User

IOS: A Multi-choice control with animation (2); ios animation control

Then let's write: TypeSelectView

This is relatively simple. We only need to position each TypeView and use it as our subview.

@interface TypeSelectView : UIView@property(nonatomic) BOOL bShown;@property(nonatomic, strong) TypeView* curSelectedView;-(id)initWithFrame:(CGRect)frame searchType:(int)type;@end

-(id)initWithFrame:(CGRect)frame searchType:(int)type{    self = [super initWithFrame:frame];    if (self) {        _bShown = NO;        self.backgroundColor = [UIColor clearColor];        CGRect rcBg = frame;        rcBg.origin.y = 0.0f;        rcBg.origin.x = 0.0f;        UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:rcBg];        bgImageView.image = [UIImage imageNamed:@"change_icon_bg.png"];        [self addSubview:bgImageView];                CGRect typeRc =CGRectMake(4.0f, 0.0f, TypeView_Width, TypeView_Height);        for (int i = 0; i < 4; i++) {            TypeView *curTypeView = [[TypeView alloc] initWithFrame:typeRc];            curTypeView.typesView = self;            curTypeView.typeId = i;            if (i == type) {                curTypeView.bSelected = YES;                self.curSelectedView = curTypeView;            }            [self addSubview:curTypeView];                        if (i == 3) {                typeRc.origin.x = 4.0f;                typeRc.origin.y = 78.0f;            }else {                typeRc.origin.x += 314.0f/4;            }        }    }        return self;}    


Then we write TopBarView
@interface TopBarView : UIView-(void)layoutViews;@property(nonatomic,strong)TopBarControllerViewController* myViewController;@property(nonatomic)UIButton* button;@property(nonatomic)UITextField* textField;@property (nonatomic, strong) TypeSelectView *topTypesView;-(void)onclick;@end

The code for adding TypeSelectView is:

-(Void) layoutViews {self. clipsToBounds = YES; _ topTypesView. bShown = NO; TypeSelectView * tmpType = [[TypeSelectView alloc] initWithFrame: [[HomePageUIManager sharedInstance] searchTypesOriginFrame] searchType: 0]; _ topTypesView. autoresizingMask = bytes | UIViewAutoresizingFlexibleWidth | bytes; _ topTypesView = tmpType; // write _ topTypesView after these views [[MyViewController sharedInstance]. view insertSubview: _ topTypesView belowSubview: self];

Add _ topTypesView to the end of [MyViewController sharedInstance]. view so that the initial position can be covered by TopBarView. the initial position of _ topTypeView is:

- (CGRect)searchTypesOriginFrame{return CGRectMake(0.0f, 44.0f- 80.0f, 320.0f, 80.0f);}


The position shown in the show is:

- (CGRect)searchTypesShowFrame{return CGRectMake(0.0f, 44.0f, 320.0f, 80.0f);}


The Code of show TypeSelectedView is to change the frame of _ topTypesView. hide is to reverse the frame.

- (void)toShowTypesView {    _topTypesView.frame = [[HomePageUIManager sharedInstance] searchTypesOriginFrame];[UIView beginAnimations:@"ShowTypes" context:NULL];[UIView setAnimationDuration:0.4f];[UIView setAnimationDelegate:self];[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];[UIView setAnimationBeginsFromCurrentState:YES];[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];    _topTypesView.bShown = YES;_topTypesView.frame = [[HomePageUIManager sharedInstance] searchTypesShowFrame];        [UIView commitAnimations];}

MyViewController initialization:

-(Id) initWithNibName :( NSString *) nibNameOrNil bundle :( NSBundle *) attributes {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization <strong> // self. view. backgroundColor = [MyViewController RGBColorFromHexString: @ "# eeeeee" alpha: 1.0f]; // do not add this sentence unless necessary, if MyViewController is added to execute viewdidload, the program will crash </strong>} return self;} // statement of the singleton + (MyViewController *) sharedInstance {static MyViewController * _ sharedInstance = nil; if (_ sharedInstance = nil) _ sharedInstance = [[MyViewController alloc] initWithNibName: nil bundle: nil]; return _ sharedInstance ;} -(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. CGRect rcSearchBar = [[HomePageUIManager sharedInstance] searchBarViewFrame]; TopBarView * tmpView = [[TopBarView alloc] initWithFrame: rcSearchBar]; [tmpView layoutViews]; [self. view addSubview: tmpView]; UIView * view = [[UIView alloc] initWithFrame: CGRectMake (0, 44,320, 2)]; view. backgroundColor = [UIColor grayColor]; [self. view addSubview: view];}

The code can be downloaded at http://download.csdn.net/detail/baidu_nod/7644329


How to use an animation control in MFC

Class CAnimateCtrl can play videos in AVI format.

A page can load two ocx controls at the same time ??

Display Flash animation using ActiveX controls in C ++ Builder

With the strong support of Microsoft, more and more software companies are beginning to support ActiveX.
It's a pleasure for friends who are happy with programming! Because we can easily call external
The OCX file of the department to implement complex functions (Bill Gates has done a good thing this time), such
To display HTML files. Today, I want to introduce how
Use ActiveX control in Builder to display Flash animation.
1. Install and import ActiveX Controls
The main character of this article is: swflash. ocx, which is included in Windows98. It is in the default mode.
Windows will install it in the "Windows \ System \ Macromed \ Flash" directory, if you
If "default installation" is not selected during installation, it can be found in the win98_68.cab file on the Win98 installation disc.
It.
In terms of ActiveX support, C ++ Builder has done a great job.
Import ActiveX Control in the system: Select "Component-> Import ActiveX Control ".
", Select" ShockWave Flash (Version 1.0) "in the above control list (Figure 1), and then
Click the "Install" button below! If it is not in the control list, ShockWave
Flash control has not been registered in the system, it doesn't matter, we can click the "Add" button in your
After finding the OCX file in the computer and then installing it, C ++ Builder automatically registers for it.
2. programming Flash animation display
After the import is successful, C ++ Builder adds a "ShockWaveFlash" to the ActiveX page"
Controls (Figure 2) to create a new project and place a ShockWaveFlash control in a proper position,
Adjust the size of the disk, and then fill in an existing one on your hard disk in its "Movie" attribute.
The Flash Animation file name (such as c: \ flash \ test.swf), and then press F9 to run.
Line of code, we made a program that can display Flash animation!
However, to make it work better, we also need to know the owner of the ShockWaveFlash control.
Features and methods:
AlignMode (int type) and SAlign (WideString type) control the animation display position
(If these two attributes are listed together, they are correlated. Changing one or the other will also change accordingly.
Changes, the following situations are not described ). The value range and meaning are as follows:
0 empty Current Position
1 L the current position is left
2 R: Right
3 LR current position Center
4 T the current position is up
5 LT upper left
6 TR upper right
7 center above LTR
8 B. The current location is down
9 LB bottom left
10 RB lower right
Center below 11 LRB
The current location of 12 TB is vertically centered
13 LTB center vertically to the left
14 TRB center vertically to the right
15 central location of LTRB
BackgroundColor (int type) and BGColor (WideString type) set the background color
, BackgroundColor is an integer value, and BGColor is its HEX string.
Loop (bool type) Loop display
Whether or not Menu (bool type) displays the right-click Menu. It is recommended to set it to true because it can finish
For most of the Flash animation control work, we do not need to write code.
The name of the Movie (WideString) Flash Animation file.

Related Article

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.