随笔分类 - UI
IOS-UI
摘要:UITextView 默认没有 pleaceholder属性;我们可以通过多种方式添加在UITextView的代理方法中写- (void)textViewDidBeginEditing:(UITextView *)textView{ if ([textView.text isEqualToString:@"建议字数在300字左右"]) { textView.text = @""; textView.textColor = [UIColor blackColor]; //optional } [textView becomeFirstResponde...
阅读全文
摘要:无意中发现,有人创建UIButton这样写UIButton *previousButton = [UIButtonbuttonWithType:101];一看原来是私有api UIButton *previousButton = [UIButton buttonWithType:101]; [previousButton setTitle:@"<" forState:UIControlStateNormal]; previousButton.frame = CGRectMake(0.f, 0.f, 30.f, 80.f); previousButton.center
阅读全文
摘要:iOS7 下使用SVPullToRefresh 下拉刷新导航栏位置错误;下拉刷新之后,tableview的第一列会跑到导航栏的下面;修正:添加如下代码 /** * 下拉刷新 增加一个; */ //修复下拉刷新位置错误 代码开始 if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) { self.automaticallyAdjustsScrollViewInsets = NO; UIEdgeInsets ...
阅读全文
摘要:ARC下 does not support automated __weak references错误此错误,通常是你的ARC下不支持weak 把你项目里面,weak的地方 改为 unsafe_unretained参考:http://stackoverflow.com/questions/6893038/how-do-i-replace-weak-references-when-using-arc-and-targeting-ios-4-0
阅读全文
摘要:iOS7 设置navigationBar的颜色,新增了一个属性 barTintColor CGFloat osVersion = [[UIDevice currentDevice].systemVersion floatValue]; if (osVersion >= 7.0) { rootNa.navigationBar.barTintColor = [UIColor redColor]; } else { rootNa.navigationBar.tintColor = [UIColor redColor]; }
阅读全文
摘要://二维码生成 //UIImageView *theImageView = [[UIImageView alloc]init]; //[self.view addSubview:theImageView]; CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; [filter setDefaults]; NSData *data = [@"hello worold!" dataUsingEncoding:NSUTF8StringEncoding]; [fi...
阅读全文
摘要:UITabBarController --》UITabBarCustomizing Appearance backgroundImage背景图片 selectedImageTintColor 选中状态 selectionIndicatorImage 选中指示器状态 shadowImageshadow图片 tintColor颜色
阅读全文
摘要:- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); UIGraphicsPushContext(context); CGRect boxRect = CGRectMake(0, 0, 90,90); float radius = 10.0f; CGContextBeginPath(context); CGContextMoveToPoint(context, CGRectGetMinX(boxRect) + radius, ...
阅读全文
摘要:一: NSDateFormatter *dateFormater = [[NSDateFormatter alloc]init]; [dateFormater setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSTimeZone* localzone = [NSTimeZone localTimeZone]; NSTimeZone* GTMzone = [NSTimeZone timeZoneForSecondsFromGMT:0]; [dateFormater setTimeZone:GTMzone]; [dateForm...
阅读全文
摘要:UISlider *aslider = [[UISlider alloc]initWithFrame:kCR(50, 50, 200, 200)]; [aslider setValue:0.5]; [aslider setThumbImage:[UIImage imageNamed:@"ssuibian .png"] forState:UIControlStateNormal]; [aslider setThumbImage:[UIImage imageNamed:@"ssuibian .png"] forState:UIControlStateHigh
阅读全文
摘要:方法一: UILabel *mindName = [[UILabel alloc]initWithFrame:kCR(0, 0, 25,40)]; mindName.text = @"苏\n小\n明"; mindName.numberOfLines = [mindName.text length]; 方法二:// NSString *text = @"一";// NSString *strText = @"苏得强";// UIFont *font = [UIFont systemFontO...
阅读全文
摘要:1:假如有6个图片:那个,Scrollview的大小加 7 个图片的大小2: //ImageScrollView; UIScrollView *imageScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 210)]; imageScroll.bounces = YES; imageScroll.pagingEnabled = YES; imageScroll.userInteractionEnabled = YES; imageScroll.showsVerticalScrollI...
阅读全文
摘要:- (float) heightForTextView: (UITextView *)textView WithText: (NSString *) strText{ float fPadding = 10.0; CGSize constraint = CGSizeMake(textView.contentSize.width - fPadding, CGFLOAT_MAX); CGSize size = [strText sizeWithFont: textView.fontconstrainedToSize:constraint lineBreakMode:NSLineBreakB...
阅读全文
摘要:一:添加通知//数字键盘添加完成 [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotificationobject:nil];二:数字键盘出现添加//键盘处理- (void)keyboardWillShow:(NSNotification *)note{ UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; doneB...
阅读全文
摘要:一:添加通知监测键盘高度变化 [selfkeyBoardAutoSize];二:动态改变高度#pragma mark keyboard height auto/* NSNotificationCenter:键盘出现、消失时的通知 UIKeyboardWillShowNotification; UIKeyboardDidShowNotification; UIKeyboardWillHideNotification; UIKeyboardDidHideNotification; */- (void) keyBoardAutoSize{ [[NSNotificationCenter d...
阅读全文
摘要:titleLabel.font = [UIFontboldSystemFontOfSize:16];
阅读全文
摘要:[UIApplicationsharedApplication].idleTimeDisabled= YES
阅读全文
摘要:自定义UITableViewCell上的delete按钮滑动列表行(UITableViewCell)出现删除按钮时,默认是英文“delete”,这份代码片段能够将“delete”变成中文”删除“,甚至可以自定义删除按钮的形状。?12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061//通过UITableViewDelegate方法可以实现删除 tableview中某一行 //滑动删除-(void)tableView:(UIT
阅读全文
摘要:iOS实现在后台播放音乐iOS4之后就支持后台播放音频了。只需下面两步就可以实现后台播放音频操作了。1. 在Info.plist中,添加"Required background modes"键,其值设置是“App plays audio"2. 在播放器播放音乐的代码所在处,添加如下两段代码(当然,前提是已经添加了AVFoundation框架):12345678910111213141516171819//添加后台播放代码:AVAudioSession *session = [AVAudioSession sharedInstance]; [session setA
阅读全文
摘要:12345678910111213//方法一:cell.contentView.backgroundColor = [UIColor redColor];//方法二:UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];UIView* bgview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];bgview.opaque = YES;bgview.backgroundColor = [UIColor orangeC
阅读全文