IOS UI 第八篇:基本UI
{
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 200)];
for (int i=1; i<=8; ++i) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg", i]];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(320*(i-1), 0, 320, 200)];
imageView.image = image;
[scrollView addSubview:imageView];
}
scrollView.bounces = NO;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.pagingEnabled = YES;
scrollView.contentSize = CGSizeMake(320*8, 200);
[self.view addSubview:scrollView];
// Do any additional setup after loading the view.
}
{
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 30, 300, 400)];
scrollView.backgroundColor = [UIColor orangeColor];
UIImage *image = [UIImage imageNamed:@"1.jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[scrollView addSubview:imageView];
scrollView.contentSize = CGSizeMake(image.size.width, image.size.height);
[self.view addSubview:scrollView];
// Do any additional setup after loading the view.
}
@property (weak, nonatomic) IBOutlet UILabel *myLabel;
@end
@implementation QFViewController{
CGFloat preScale;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// 手势
/*
UITapGestureRecognizer;//单击
UIPinchGestureRecognizer;//缩放手势
UIRotationGestureRecognizer;//旋转手势
UISwipeGestureRecognizer;//扫动手势(上下左右)
UIPanGestureRecognizer;//滑动手势
*/
UIPinchGestureRecognizer *pinchGR=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(onPinch:)];
[self.myLabel addGestureRecognizer:pinchGR];
//label、imageview默认不接受人机交互,要手动设置
self.myLabel.userInteractionEnabled=YES;
preScale=1;
}
-(void)onPinch:(UIPinchGestureRecognizer *)pGR{
NSLog(@"%@",pGR);
NSLog(@"%f",pGR.scale);
/*
UIGestureRecognizerStateBegan,
UIGestureRecognizerStateChanged,
UIGestureRecognizerStateEnded,
*/
if (pGR.state==UIGestureRecognizerStateChanged) {
self.myLabel.font=[UIFont systemFontOfSize:17*preScale*pGR.scale];
}
if (pGR.state==UIGestureRecognizerStateEnded) {
preScale=preScale*pGR.scale;
}
}
@end
IOS UI 第八篇:基本UI
最新文章
- 常用jQuery 方法
- bzoj 1305 dance跳舞
- $.ajax请求返回数据中status为200,回调的却是error?
- C#中委托实现的异步编程
- .NET逻辑分层架构总结
- 转帖:用五分钟重温委托,匿名方法,Lambda,泛型委托,表达式树
- 一个动画 Label (走马观花)
- 【读书笔记】读《JavaScript模式》 - 函数复用模式之现代继承模式
- CF Destroying Roads (最短路)
- IP地址,子网掩码、默认网关,DNS理论解释
- 【转】Linux下查看所有用户及用户组
- TEA加密算法的文件加密和解密的实现
- (asp.net MVC学习)System.Web.Mvc.UrlHelper的学习与使用
- 2px边框,4分之1内边框实现选中功能实现
- 《C++之那些年踩过的坑(二)》
- jmeter监控服务资源
- 设计模式之创建类模式PK
- create-react-app创建项目并用git上传至GitHub及展示预览效果
- Python——hashlib
- Unity3d — — UGUI之Box Collider自适应大小
热门文章
- 数据库文档生成工具——word2chm,SqlSpec
- Android fragment onActivityResult 不起作用
- 如何让格斗游戏的横版过关(2) Cocos2d-x 2.0.4
- C++ 之 exception
- MD5算法的原理与实现
- freemarker定义自己的标记(三)-nested说明
- List之Distinct()
- zabbix-agent TIME_WAIT 过多
- redis修改的源代码zincrby,hincrby命令
- POJ 3067 Japan 树状数组求逆序对