随记(一)
来源:互联网 发布:windows xp是多少位 编辑:程序博客网 时间:2024/05/01 06:05
1.视图位置
//将一个UIView显示在最前面只需要调用其父视图的 bringSubviewToFront()//将一个UIView层推送到背后只需要调用其父视图sendSubviewToBack()//插入到某一层[self.view insertSubview:toolBar aboveSubview:self.tableView];
2 单例传值
//存值 NSUserDefaults * user = [NSUserDefaults standardUserDefaults]; [user setObject:selStr forKey:@"selStr”];[user synchronize];//取值NSUserDefaults *defau = [NSUserDefaults standardUserDefaults]; [rightTextArray replaceObjectAtIndex:selIndex withObject:[defau objectForKey:@"selStr"]];//滚动tableView到指定节section[myTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:button.tag] atScrollPosition:UITableViewScrollPositionTop animated:YES];
3 图片边框阴影
//阴影层: CALayer *layer = [_titleImage layer]; layer.shadowOffset = CGSizeMake(0, 2); layer.shadowRadius = 3.0; layer.shadowColor = [UIColor blackColor].CGColor; layer.shadowOpacity = 0.5;
4 cell入场动画
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.scale"]; cell.layer.anchorPoint = CGPointMake(.5,.5); animation.fromValue = @0.0f; animation.toValue = @1.0f; animation.duration=1;// animation.autoreverses=YES;//是否反转变为原来的属性值 //把animation添加到图层的layer中,便可以播放动画了。forKey指定要应用此动画的属性 [cell.layer addAnimation:animation forKey:@"scale"];
5 视图旋转动画
链接:http://zhangmingwei.iteye.com/blog/2101782
//旋转动画。[self.view.layer addAnimation:[self rotation:1 degree:180 direction:0 repeatCount:MAXFLOAT] forKey:nil];-(CABasicAnimation *)rotation:(float)dur degree:(float)degree direction:(int)direction repeatCount:(int)repeatCount{ CATransform3D rotationTransform = CATransform3DMakeRotation(degree, 0, 1, direction); CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; animation.toValue = [NSValue valueWithCATransform3D:rotationTransform]; animation.duration = dur; animation.autoreverses = NO; animation.cumulative = NO; animation.fillMode = kCAFillModeForwards; animation.repeatCount = repeatCount; animation.delegate = self; return animation;}
6 计算文本高度
CGSize constraint = CGSizeMake(self.frame.size.width, 20000);CGSize size = [@"哈哈哈哈哈哈哈哈" boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]}context:nil].size;
7 cell刷新
//一个section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2]; [tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; //一个cell刷新 NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0]; [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
8 去掉UItableview headerview黏性(sticky)
//去掉UItableview headerview黏性(sticky) UITableViewStylePlain- (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView == groupTableView) { CGFloat sectionHeaderHeight = 50; //sectionHeaderHeight if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) { scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0); } else if (scrollView.contentOffset.y>=sectionHeaderHeight) { scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0); } }}
9 摇一摇
#pragma mark - 生命周期函数 - (void)viewDidLoad { [super viewDidLoad]; // 设置允许摇一摇功能 [UIApplication sharedApplication].applicationSupportsShakeToEdit = YES; // 并让自己成为第一响应者 [self becomeFirstResponder]; return; } #pragma mark - 摇一摇相关方法 // 摇一摇开始摇动 - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"开始摇动"); return; } // 摇一摇取消摇动 - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"取消摇动"); return; } // 摇一摇摇动结束 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.subtype == UIEventSubtypeMotionShake) { // 判断是否是摇动结束 NSLog(@"摇动结束"); } return; }
0 0
- 随记(一)
- 随记一
- 随记(一)
- 孕妇随记(一)
- 随记系列一
- 学习随记(一)
- Android:ViewPager 随记一
- 工作随记(一)
- 随记(一)
- ocp学习随记(一)
- 移动产品设计随记(一)
- Android学习随记(一)
- Android:百度地图随记一
- C语言随记(一)
- threejs学习随记(一)
- angular随记(一)自定义指令
- 随记
- 随记
- linux svn 取代码报错
- Android Action广播大全,开机自启动的服务
- 并发与实例模式
- JDK并发工具类源码学习系列——LinkedBlockingQueue
- Linux初学实战之管道piple
- 随记(一)
- Linux系统调用列表
- 正则表达式所有元字符及其使用方法一览表
- jupyter notebook的安装、配置
- 中文 iOS/Mac 开发博客列表
- self.title 与 self.navigationItem.title 的区别
- css background属性
- MYSQL 常用查詢
- 【Linux C/C++】 第01讲 HelloWorld程序内存分区详解