ios开发过程中的一些笔记,不断更新中。。。
来源:互联网 发布:mac os 常用软件 编辑:程序博客网 时间:2024/04/30 15:58
记录学习中的点点滴滴:
1、一个类,无论是继承自nsobject还是继承自uiviewcontroller,初始化一些东西时,难免需要程序运行后只走一遍,例如一些页面的初始值,一些model的初始值。当我们需要只是运行程序就会初始化一次时,我们可以调用这两个方法:
+(void)initialize{
}
+(void)load{
}
这两个方法,在程序运行后会执行,而且只会执行一次2、设置button的标题与button的边界的距离,例如不是设置标题居中的,而是标题离右边界的距离为30像素,那么需要先设置button的内容的对齐方式
startButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
然后,定义一个UIEdgeInsets
UIEdgeInsets edgeInset =UIEdgeInsetsMake(0,0,0,30);
最后设置button的titleEdgeInsets为自己定义的UIEdgeInsets
startButton.titleEdgeInsets = edgeInset
成功!!
3、设置UIDatePicker的显示中英文问题
NSLocale *locale = [[NSLocalealloc]initWithLocaleIdentifier:@"en_US"];//设置为英文显示
NSLocale *locale = [[NSLocalealloc]initWithLocaleIdentifier:@"zh_CN"];//设置为中文显示
datePicker.locale = locale;
ok!!!
4、设置UIDatePicker的显示
// 0-大背景的颜色; 1-选择框左边的颜色; 2-? ;3-?; 5-滚动区域的颜色 回覆盖数据
//6-选择框的背景颜色 7-选择框左边的颜色 8-整个View的颜色 会覆盖所有的图片
UIView *view = [[self subviews] objectAtIndex:6];
[view setBackgroundColor:[UIColor clearColor]];
UIImageView *bgimg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"picker_tiao.png"]];
bgimg.frame = CGRectMake(-5, -3, 200, 55);
[view addSubview:bgimg];
[self setNeedsDisplay];
ok!!!
5、获取键盘的高度
首先注册一个通知,当键盘弹出的时候通知我
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil];
然后,当键盘弹出的时候,通过objectForKey:的UIKeyboardFrameBeginUserInfoKey对应的值来获取键盘的高度
- (void) keyboardWasShown:(NSNotification *) notif{
NSDictionary *info = [notif userInfo];
NSValue *value = [info objectForKey:UIKeyboardFrameBeginUserInfoKey];
CGSize keyboardSize = [value CGRectValue].size;
NSLog(@"keyBoard:%f", keyboardSize.height); //216
keyboardWasShown = YES;
}
OK!!!
6、让一个图片不断旋转
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimationanimationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumbernumberWithFloat:M_PI *2.0 ];
[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
rotationAnimation.duration =10;
rotationAnimation.repeatCount =9999;//你可以设置到最大的整数值
rotationAnimation.cumulative =NO;
rotationAnimation.removedOnCompletion =NO;
rotationAnimation.fillMode =kCAFillModeForwards;
[self.weatherImageView.layeraddAnimation:rotationAnimationforKey:@"Rotation"];
7、修改pagecontrol的圆点的颜色
UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame: ... pageControl.numberOfPages = 5;
pageControl.currentPageIndicatorTint
pageControl.pageIndicatorTintColor = [UIColor greenColor];
搞定了!!
8、判断当前设备是否为iphone
[[UIDevicecurrentDevice]userInterfaceIdiom] ==UIUserInterfaceIdiomPhone
[[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad 判断当前设备是否为ipad
9、让一个图片围绕一个点旋转
-(void)startAnimation
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.05];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startAnimation)];
self.angle += 5;
self.saomiao.layer.anchorPoint = CGPointMake(1,1);//以右下角为原点转,(0,0)是左上角转,(0.5,0,5)心中间转,其它以此类推
self.saomiao.transform = CGAffineTransformMakeRotation(self.angle * (M_PI / 180.0f));
[UIView commitAnimations];
}
不断更新中。。。。
- ios开发过程中的一些笔记,不断更新中。。。
- 一些开发或使用软件过程中的经验(不断更新)
- 学习iOS开发的一些网站(不断更新)
- 系统开发过程中的问题集!!(不断更新)
- iOS开发中的小问题,不断更新
- iOS开发笔记之六十七——Category使用过程中的一些注意事项
- IOS开发 开发过程中的一些尺寸问题
- IOS开发中一些重要提示笔记
- iOS开发过程中的一些错误提示和解决办法大全
- linux C 学习中的一些小笔记,不断更新
- OSG程序编译与开发过程中的问题(不断更新)
- 一些网站-不断更新中。。。。
- Android开发过程中遇到的“错误”...不断更新中...
- ios开发学习过程中遇到的一些问题
- ios开发过程中一些常用地址收集整理
- iOS开发过程中一些数据的存储归档
- iOS开发过程中使用一些常用的宏
- VS.NET2005中的一些小知识(不断更新中...)
- 【算法竞赛题解】:abc:def:ghi = 1:2:3,有新巧妙解法支付宝转5块
- SQLite的基本使用
- ThinkPHP3.2中Widget实例的使用
- redo log和undo log的区别
- 修改EIP注入DLL入的一个示例
- ios开发过程中的一些笔记,不断更新中。。。
- 新浪微博分享
- 什么是 csdn
- 六款值得推荐的android(安卓)开源框架简介
- DirectX11 演示程序框架
- android使用GestureDetector实现手势下滑与ListView onTouchEvent 冲突问题 解决
- Qt中在QMAinWindow内添加layout出现问题
- 幸存者偏差——讨论死在中国游戏圈的一百万种方式
- ios 公共类的合理使用