iOS -UI-视图创建及动画的实现
来源:互联网 发布:windows phone7.8 编辑:程序博客网 时间:2024/05/22 17:37
//
// ViewController.m
// UI-视图练习
//
// Created by jzq_mac on 15/7/23.
// Copyright (c) 2015年 jzq_mac. All rights reserved.
//
#import "ViewController.h"
@interfaceViewController ()
{
UIButton *button;
UILabel *label;
UITextField *textFiled;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.view.backgroundColor = [UIColorblackColor];
[NSTimerscheduledTimerWithTimeInterval:4target:selfselector:@selector(moveAction)userInfo:nilrepeats:YES];
// UIButton 练习
button = [UIButtonbuttonWithType:UIButtonTypeCustom];
button.frame =CGRectMake(150,567, 100, 100);
[self.viewaddSubview:button];
button.layer.cornerRadius =50;
button.backgroundColor = [UIColorblueColor];
// [button setTitle:@"点我啊" forState:UIControlStateNormal];
[buttonsetTitle:@"点我干嘛"forState:UIControlStateSelected];
button.showsTouchWhenHighlighted =YES;
[buttonsetTitleColor:[UIColorredColor] forState:UIControlStateNormal];
button.titleLabel.font = [UIFontsystemFontOfSize:20];
button.clipsToBounds =YES;
button.contentMode =YES;
button.alpha =0.8;
[buttonsetTitleShadowColor:[UIColoryellowColor] forState:UIControlStateNormal];
[buttonsetBackgroundImage:[UIImageimageNamed:@"苹果"]forState:UIControlStateNormal];
[buttonaddTarget:selfaction:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
// UIlabel 练习
label = [[UILabelalloc]initWithFrame:CGRectMake(170,70, 50, 500)];
[self.viewaddSubview:label];
label.backgroundColor = [UIColorredColor];
label.text =@"梦想还是要有的 万一实现了呢";
label.layer.cornerRadius =50;
label.layer.masksToBounds =YES;
label.textColor = [UIColoryellowColor];
label.textAlignment =NSTextAlignmentCenter;
label.font = [UIFontsystemFontOfSize:30];
label.numberOfLines =50;
for (int i =0; i < 2; i ++) {
UIImageView *imgeView = [[UIImageViewalloc]initWithFrame:CGRectMake(20 + (240 + 20)*i, 587, 80,80)];
[self.viewaddSubview:imgeView];
imgeView.backgroundColor = [UIColorredColor];
imgeView.layer.cornerRadius =40;
imgeView.layer.masksToBounds =YES;
imgeView.image = [UIImageimageNamed:@"苹果1"];
imgeView.tag = i +100;
}
textFiled = [[UITextFieldalloc]initWithFrame:CGRectMake(0,0, 375,50)];
textFiled.delegate =self;
[self.viewaddSubview:textFiled];
textFiled.backgroundColor = [UIColorgrayColor];
textFiled.placeholder =@"欢迎来到星际穿越";
textFiled.textAlignment =NSTextAlignmentCenter;
textFiled.font = [UIFontsystemFontOfSize:30];
textFiled.returnKeyType =UIReturnKeyDefault;
UIImageView *left = [[UIImageViewalloc]initWithFrame:CGRectMake(0,0, 50,50)];
left.image = [UIImageimageNamed:@"拳头"];
textFiled.leftView = left;
textFiled.leftViewMode =UITextFieldViewModeAlways;
textFiled.alpha =0.5;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textFiledresignFirstResponder];
return YES;
}
- (void)moveAction
{
// 图片移动练习
[UIViewanimateWithDuration:2animations:^{button.frame =CGRectMake(150,0, 100,100);} completion:^(BOOL finished){[UIViewanimateWithDuration:2animations:^{button.frame =CGRectMake(150,567, 100, 100);}];}];
for (int i =0; i<2; i++) {
UIImageView *imgeView = (UIImageView *)[self.viewviewWithTag:i+100];
if (imgeView.tag ==100) {
imgeView.alpha =1;
[UIViewanimateWithDuration:2animations:^{
imgeView.alpha =0.0;
}];
[UIViewanimateWithDuration:2animations:^{
imgeView.frame =CGRectMake(160,10, 80, 80);
} completion:^(BOOL finished) {
[UIViewanimateWithDuration:2animations:^{
imgeView.frame =CGRectMake(20,587, 80, 80);
}];
}];
}else{
imgeView.alpha =1;
[UIViewanimateWithDuration:2animations:^{
imgeView.alpha =0.0;
}];
[UIViewanimateWithDuration:2animations:^{
imgeView.frame =CGRectMake(160,10, 80, 80);
} completion:^(BOOL finished) {
[UIViewanimateWithDuration:2animations:^{
imgeView.frame =CGRectMake(270,587, 80, 80);
}];
}];
}
}
label.alpha =1;
[UIViewanimateWithDuration:4animations:^{
label.alpha =0.0;
}];
label.text =@"梦想还是要有的 万一实现了呢";
[UIViewanimateWithDuration:3animations:^{
label.text =@"梦想还是要有的 万一实现了呢";
} completion:^(BOOL finished) {
[UIViewanimateWithDuration:1animations:^{
label.text = @"我就是我颜色不一样的花火";
}];
}];
}
- (void)click:(UIButton *)sender
{
if (sender.selected !=YES) {
[buttonsetBackgroundImage:[UIImageimageNamed:@"星际"]forState:UIControlStateNormal];
[buttonsetTitle:@"点我啊"forState:UIControlStateNormal];
sender.selected =YES;
}else{
[buttonsetBackgroundImage:[UIImageimageNamed:@"拳头"]forState:UIControlStateNormal ];
[buttonsetTitle:@"点我干嘛"forState:UIControlStateSelected];
sender.selected =NO;
}
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- iOS -UI-视图创建及动画的实现
- iOS巅峰之UI视图动画详解
- 实现视图的动画
- iOS开发 UI实现的三种动画
- UI -- CATransition的动画效果类型及实现方法
- IOS视图切换实现简单动画
- 在iOS利用动画实现全景视图
- ios--视图控制器的创建
- IOS 自定义视图的创建
- IOS--UI:按钮,文本框,标签,文本视图创建
- UI创建霓虹灯视图
- UI设计 创建视图
- IOS UI初级-表视图的使用
- IOS开发UI-------视图的生命周期
- IOS 全局UI的创建
- IOS创建UI的方式
- ios 视图动画的Option枚举值
- iOS小米遥控器的手势监听及UI实现
- C++第二节(2):复合类、析构函数、new、delete
- ubuntu lamp搭建
- 从hadoop框架与MapReduce模式中谈海量数据处理
- UVA 621 Secret Research
- 网络编程
- iOS -UI-视图创建及动画的实现
- Geek(极客) 头条分析
- HDU--1061
- Nginx worker工作流程
- Visual Studio Code
- JVM的相关知识整理和学习
- 反射
- 客户端网页编程1、2
- KM算法模板