首页 文章 精选 留言 我的

精选列表

搜索[ios],共10000篇文章
优秀的个人博客,低调大师

ios 上拉载入下拉刷新Dome

为练手写了一个小的上拉载入很多其它下拉刷新的小的Dome 。 没有太多的技术含量,仅仅是作为新手的启示用。是上一篇下拉载入的扩展。先看一下那个再看这个就easy非常多。 Dome下载:http://download.csdn.net/detail/u010123208/8062715 先来梳理一下: 上拉家在很多其它就是上拉之后在底部现实一个视图,用来提示用户上拉载入很多其它,假设用户上拉就出发事件。进行载入并在试图中给予提示,同一时候后台载入数据,将加入的数据加入数据数组,最后又一次导入列表; 下拉刷新相同的操作,仅仅只是就是将数组清空又一次来导入数据; 首先我们要创建两个view 一个是顶部显示,一个在底部显示 ; 在view中要显示如今文字,一张图片,一个活动指示框(当进行网络请求载入数据的时候显示。其它时候隐藏),假设不太理解下载Dome看一下就知道了。 typedef enum { InsertStateNomal, //寻常状态 InsertStateDrapUp, //上拉状态 InsertStateDrapDown, //下拉状态 InsertStateRun, //正在载入的状态 }InsertState; @interface HeadView : UIView @property (nonatomic,strong) UIImageView *imageView; @property (nonatomic,strong) UILabel *label; @property (nonatomic,assign) InsertState insertState; @property (nonatomic,strong) UIActivityIndicatorView *activity; - (void)setInsertNomal; - (void)setInsertDrapDown; - (void)setInsertRun; @end @interface FootView : UIView @property (nonatomic,strong) UIImageView *imageView; @property (nonatomic,strong) UILabel *label; @property (nonatomic,assign) InsertState insertState; @property (nonatomic,strong) UIActivityIndicatorView *activity; - (void)setInsertNomal; - (void)setInsertDrapDoUp; - (void)setInsertRun; @end 枚举用来指示视图的当前状态; 事实上两个视图的内容什么的都全然一样; // // InsertView.m // RefreshDome // // Created by 小屁孩 on 14-10-16. // Copyright (c) 2014年 XS. All rights reserved. // #import "InsertView.h" @implementation HeadView @synthesize imageView; @synthesize label; @synthesize insertState; @synthesize activity; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor orangeColor]; //图片 imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"arrow.png"]]; imageView.frame = CGRectMake(20, frame.size.height-60, 30, 50); [self addSubview:imageView]; //显示的文字 label = [[UILabel alloc]initWithFrame:CGRectMake(60, frame.size.height-60, 250, 50)]; label.text = @"下拉刷新..."; label.textAlignment = NSTextAlignmentCenter; [self addSubview:label]; //状态 insertState = InsertStateNomal; //活动指示器 activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; activity.frame = CGRectMake(20,frame.size.height-60, 30, 50); [self addSubview:activity]; } return self; } //初始状态 -(void)setInsertNomal { insertState = InsertStateNomal; label.text = @"下拉刷新....."; imageView.layer.transform = CATransform3DMakeRotation(M_PI*2, 0, 0, 1); [activity stopAnimating]; imageView.hidden =NO; } //下拉状态 - (void)setInsertDrapDown { insertState = InsertStateDrapDown; [UIView beginAnimations:nil context:nil]; label.text = @"释放后刷新....."; imageView.layer.transform = CATransform3DMakeRotation(M_PI, 0, 0, 1); [UIView commitAnimations]; } //刷新状态 - (void)setInsertRun { insertState =InsertStateRun; label.text = @"正在刷新....."; imageView.hidden = YES; [activity startAnimating]; } @end @implementation FootView @synthesize imageView; @synthesize label; @synthesize insertState; @synthesize activity; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor orangeColor]; //图片 imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"arrow.png"]]; imageView.layer.transform = CATransform3DMakeRotation(M_PI , 0, 0, 1); imageView.frame = CGRectMake(20, 10, 30, 50); [self addSubview:imageView]; //文字 label = [[UILabel alloc]initWithFrame:CGRectMake(60, 10, 250, 50)]; label.text = @"上拉载入很多其它....."; label.textAlignment = NSTextAlignmentCenter; [self addSubview:label]; //状态 insertState = InsertStateNomal; //活动指示器 activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; activity.frame = CGRectMake(20, 10, 30, 50); [self addSubview:activity]; } return self; } //初始状态 - (void)setInsertNomal { insertState = InsertStateNomal; label.text = @"上拉载入很多其它....."; imageView.layer.transform = CATransform3DMakeRotation(M_PI , 0, 0, 1); [activity stopAnimating]; imageView.hidden =NO; } //上拉状态 - (void)setInsertDrapDoUp { insertState = InsertStateDrapUp; [UIView beginAnimations:nil context:nil]; label.text = @"释放后载入很多其它....."; imageView.layer.transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1); [UIView commitAnimations]; } //载入状态 - (void)setInsertRun { insertState = InsertStateRun; label.text = @"正在载入....."; imageView.hidden = YES; [activity startAnimating]; } @end 最后就是列表了; 事实上在这里面须要注意的: 要如何为表格加入视图 加入的底部视图随着内容的增多,是不断变化的(这里我用了KVO来控制,当数组元素变化后处理位置) 当完毕下拉或者上拉的时候。短暂的视图显示怎么来控制 上拉下拉的推断(UIScrollview代理)条件; #import <UIKit/UIKit.h> #import "InsertView.h" @interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate> @property (weak, nonatomic) IBOutlet UITableView *table; @property (nonatomic,strong) NSMutableArray *tableArray; @end #import "ViewController.h" @interface ViewController () @end @implementation ViewController { HeadView *headView; FootView *footView; } @synthesize tableArray; @synthesize table; - (void)viewDidLoad { [super viewDidLoad]; table.frame = CGRectMake(0, 20, 320, [[UIScreen mainScreen]bounds].size.height-20); table.delegate = self; table.dataSource = self; table.tableFooterView = [[UIView alloc]init]; //下拉头部视图 headView = [[HeadView alloc]initWithFrame:CGRectMake(0, -251, DEVICE_FRAME.size.width, 251)]; [table addSubview:headView]; //上拉底部视图 footView = [[FootView alloc]initWithFrame:CGRectMake(0, table.frame.size.height, DEVICE_FRAME.size.width, 251)]; [table addSubview:footView]; //初始化数组 tableArray = [NSMutableArray array]; for (int i = 0; i<15; i++) { NSURL *url=[NSURL URLWithString:@"http://www.sinaimg.cn/qc/photo_auto/chezhan/2012/50/00/15/80046_950.jpg"]; UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]]; [tableArray addObject:image]; } float hight =tableArray.count * 60 ; if (tableArray.count * 60 < [[UIScreen mainScreen]bounds].size.height ) { hight = table.frame.size.height; } footView.frame = CGRectMake(0, hight, 320, 251); [self addObserver:self forKeyPath:@"tableArray" options:NSKeyValueObservingOptionNew context:nil]; } - (void) addtableMutableArray { for (int i = 0; i<5; i++) { NSURL *url=[NSURL URLWithString:@"http://www.sinaimg.cn/qc/photo_auto/chezhan/2012/50/00/15/80046_950.jpg"]; UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]]; [self.tableArray addObject:image]; } self.tableArray = tableArray; [footView setInsertNomal]; [self performSelectorOnMainThread:@selector(endThread) withObject:nil waitUntilDone:NO]; } - (void)endThread { [UIView beginAnimations:nil context:nil]; table.contentInset = UIEdgeInsetsMake(0, 0, 0, 0); [UIView commitAnimations]; [table reloadData]; NSLog(@"%d",tableArray.count); } - (void) refesh { NSMutableArray *array = [NSMutableArray array]; for (int i = 0; i<15; i++) { NSURL *url=[NSURL URLWithString:@"http://wenwen.sogou.com/p/20110923/20110923201826-1347223277.jpg"]; UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]]; [array addObject:image]; } self.tableArray = array; [headView setInsertNomal]; [self performSelectorOnMainThread:@selector(endThread) withObject:nil waitUntilDone:NO]; } #pragma mark KVO -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { NSMutableArray *array = [change objectForKey:@"new"]; float hight =array.count * 60; if (array.count * 60 < [[UIScreen mainScreen]bounds].size.height ) { hight = [[UIScreen mainScreen]bounds].size.height; } footView.frame = CGRectMake(0, hight, 320, 251); } #pragma mark tabledelegate - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return tableArray.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 60; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identityCell = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identityCell]; if (cell == nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identityCell]; } cell.imageView.image = [tableArray objectAtIndex:indexPath.row]; cell.textLabel.text = @"NibBi"; return cell; } #pragma mark - scrolldelegae - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { if (headView.insertState == InsertStateDrapDown) { [UIView beginAnimations:nil context:nil]; table.contentInset = UIEdgeInsetsMake(70, 0, 0, 0); [headView setInsertRun]; [UIView commitAnimations]; [self performSelectorInBackground:@selector(refesh) withObject:nil]; } if (footView.insertState == InsertStateDrapUp) { [UIView beginAnimations:nil context:nil]; table.contentInset = UIEdgeInsetsMake(0, 0, 70, 0); [footView setInsertRun]; [UIView commitAnimations]; [self performSelectorInBackground:@selector(addtableMutableArray) withObject:nil]; } } -(void)scrollViewDidScroll:(UIScrollView *)scrollView { // NSLog(@"%f",scrollView.contentOffset.y); //上拉载入很多其它转换 if (scrollView.contentOffset.y > scrollView.contentSize.height - scrollView.frame.size.height + 60 && footView.insertState == InsertStateNomal) { [UIView beginAnimations:nil context:nil]; [footView setInsertDrapDoUp]; [UIView commitAnimations]; } //下拉刷新转换 if (scrollView.contentOffset.y < -60 && headView.insertState == InsertStateNomal) { [UIView beginAnimations:nil context:nil]; [headView setInsertDrapDown]; [UIView commitAnimations]; } } @end 本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5099195.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS 小项目--小费计算器

这个例子是 iPhone应用程序开发名师解析 上的一个小例子,基于Xcode4.3.1的工程开发 效果截图: 1.创建一个新工程叫TipCalculator; File->New->Project ->single View Application -> next. 2.布局界面 其中包含9个静态Label标签一个动态Label标签,他根据slider值的变化而能变化,然后是9个Textfield和一个slider滑动条 另外需要对TextField属性设置,text设置为0.00,然后键盘选择成Number Pad类型的,只需要对第一个最长的TextfIeld设置一下键盘类型就行,其他的不用设置,其他的8个标签显示了灰色数字,设置的是Placeholder属性; 3.设计代码,我们选择左上角的Editor图标,点击出现视图编辑框分为XIB文件,和TipCalculatorViewController.h文件 如果没有出现TipCalculatorViewController.h,我们可以根据Automatic文件进行切换 4.右键选中最长的那个TextField文件拖动到右边TipCalculatorViewController.h文件@end前面, 然后弹出一个框框,Connection选为Outlet,Storage选为Strong, 5.这样我们第一个TextField关联成功,其他的一样, 关联Slider时候,我们对他设置一些属性,(原本是最小值设为0最大值设为0.3但是我在拖动滑动条时候滑动条总是自动变为0,这样修改后问题就可以解决了),他还有一个和calculate的关联方法, 我们还需要添加两个方法,并声明一个NSString类的对象 总的代码为 #import <UIKit/UIKit.h> @interface TipCalculatorViewController : UIViewController { NSString *billTotal; } @property (strong, nonatomic) IBOutlet UITextField *billField; @property (strong, nonatomic) IBOutlet UITextField *tipFieldTen; @property (strong, nonatomic) IBOutlet UITextField *tipFieldFifteen; @property (strong, nonatomic) IBOutlet UITextField *tipFieldTwenty; @property (strong, nonatomic) IBOutlet UITextField *totalFieldTen; @property (strong, nonatomic) IBOutlet UITextField *totalFieldFifteen; @property (strong, nonatomic) IBOutlet UITextField *totalFieldTwenty; @property (strong, nonatomic) IBOutlet UITextField *tipFieldCustom; @property (strong, nonatomic) IBOutlet UITextField *totalFieldCustom; @property (strong, nonatomic) IBOutlet UISlider *customPercentSlider; @property (strong, nonatomic) IBOutlet UILabel *customLabel; -(IBAction)calculate:(id)sender;//计算小费 -(IBAction)backGrounfTap:(id)sender;//处理隐藏键盘 @end 6.因为本人在拖控件是界面设计的不够好,弹出键盘时会覆盖住下面两个TextField,所以添加了一个隐藏键盘的方法,我们把整个背景View视图当做一个大按钮,当输入完金额后点击背景就会隐藏键盘,还是选中XIB文件,然后把View类修改UIControl,然后打开关联事件,选中Touch Down 然后会弹出两个方法,backGrounfTap和calculate(注.原本是想写成backGroundTap,单词写错了变成backGrounfTap,为了其他地方不再修改,就按照backGrounfTap写了),xuanzhbackGrounfTap方法, //处理键盘 -(IBAction)backGrounfTap:(id)sender { [billField resignFirstResponder]; [tipFieldCustom resignFirstResponder]; [totalFieldCustom resignFirstResponder]; } 为什么只把三个TextField注册为了第一响应,完全按照自己意愿添加,但是最低我们要保证billField第一个添加上,其他的想添加不想添加都无所谓,只是个人觉得多添加的两个体验会好一点; 7.主要就是calculate方法实现部分 //当调出的键盘被触摸了某个数时或者某个按钮调用此方法 -(IBAction)calculate:(id)sender { // 标记是否是由用户触发 static BOOL toggle =YES; if (toggle) { // 设置标志位,此方法的下次调用由程序触发 toggle=NO; // 取出billField文本值 NSString *billFieldText = billField.text; // 将billFieldText字符串类型转换成浮点型 float newTotal = [billFieldText floatValue]; // 获取滑动条的值 float customTipPercent = customPercentSlider.value; // 事件由billField触发 if (sender == billField) { // 通过比较billField字符长度,检测billField值是否改变 if(billFieldText.length < billTotal.length) billTotal = [NSString stringWithFormat:@"%.02f",newTotal/10]; // 用户输入数字 else billTotal = [NSString stringWithFormat:@"%.02f",newTotal*10]; // 取出billTotal赋给billField文本值 billField.text = billTotal; // 将billTotal转换成浮点型,newTotal设置为新值 newTotal = [billTotal floatValue]; // 按照10% 15% 20%计算小费值 float tenTip = newTotal*0.1; float fifteenTip = newTotal*0.15; float twentyTip = newTotal*0.2; // 显示Tip栏小费值 tipFieldTen.text = [NSString stringWithFormat:@"%.02f",tenTip]; tipFieldFifteen.text = [NSString stringWithFormat:@"%.02f",fifteenTip]; tipFieldTwenty.text = [NSString stringWithFormat:@"%.02f",twentyTip]; // 设置toatal栏中显示值 totalFieldTen.text = [NSString stringWithFormat:@"%.02f",newTotal+tenTip]; totalFieldFifteen.text = [NSString stringWithFormat:@"%.02f",newTotal+fifteenTip]; totalFieldTwenty.text = [NSString stringWithFormat:@"%.02f",newTotal+twentyTip]; } // 当事件由customPercentSlider触发时 else if (sender == customPercentSlider) { // 显示滑动条变化值 customLabel.text = [NSString stringWithFormat:@"%i%%",(int)customTipPercent]; // 把按钮值赋给滑动条的值,其中对浮点型值进行了强制转换 customPercentSlider.value=(int)customTipPercent; customTipPercent = (int)customTipPercent; } // 计算小费,因为滑动条值为0~30,所以需要除以100求出小费率 float customTip = customTipPercent/100 * newTotal; tipFieldCustom.text = [NSString stringWithFormat:@"%.02f",customTip]; // 表示应付的总金额 totalFieldCustom.text =[NSString stringWithFormat:@"%.02f",customTip+newTotal]; } else { toggle=YES; } } 8.当我们输入时候,有个特别要求,假如用户小费12元,我们应输入1200,然后他们会自动变成12.00元,主要通过 通过比较 if billTotal 用户输入数字 else billTotal 实现方法,通过比较billField原来字符串长度检测用户是否改变金额,来变得小费和总的金额; 源代码:http://download.csdn.net/detail/duxinfeng2010/4464095 本文转自新风作浪 51CTO博客,原文链接:http://blog.51cto.com/duxinfeng/1208729,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS Xcode pch文件的路径配置

1、Build Setting 设置中(搜索Prefix Header) 找到Precomplie Prefix Header 这项设置设置成YES。 2、把Precomplie Prefix Header下面一项Prefix Header 双击打开,把pch文件拖到打开的对话框中,回车。 3、把$(SRCROOT) 拷贝代替Prefix Header 中的路径 替换前为:/Users/beiliu/Desktop/shui/test/Prefix.pch 替换后为:$(SRCROOT)/test/Prefix.pch, 回车搞定 本文转自 卓行天下 51CTO博客,原文链接:http://blog.51cto.com/9951038/1894051,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS图像处理之画圆角矩形

CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); //画圆矩形 //设置线宽 CGContextSetLineWidth(ctx, BORDE_WIDTH); //设置填充颜色和画笔颜色 CGContextSetFillColorWithColor(ctx, self.color.CGColor); CGContextSetStrokeColorWithColor(ctx, [UIColor yellowColor].CGColor); CGPathRef clippath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake([self offsets].width,[self offsets].height, [self size].width, [self size].height) cornerRadius:CR_RADIUS].CGPath; CGContextAddPath(ctx, clippath); // //找到各个角点 // CGPoint p_0_0 = CGPointMake([self offsets].width, [self offsets].height); // CGPoint p_0_1 = CGPointMake([self offsets].width + [self size].width, [self offsets].height); // CGPoint p_1_0 = CGPointMake([self offsets].width, [self offsets].height + [self size].height); // CGPoint p_1_1 = CGPointMake([self offsets].width + [self size].width, [self offsets].height + [self size].height); // CGContextMoveToPoint(ctx, p_1_0.x , p_1_0.y - CR_RADIUS * 2); // CGContextAddArcToPoint(ctx, p_0_0.x, p_0_0.y, p_0_0.x + CR_RADIUS*2, p_0_0.y, CR_RADIUS); // CGContextAddArcToPoint(ctx, p_0_1.x, p_0_1.y, p_0_1.x, p_0_1.y + CR_RADIUS*2, CR_RADIUS); // CGContextAddArcToPoint(ctx, p_1_1.x, p_1_1.y, p_1_1.x - CR_RADIUS*2, p_1_1.y, CR_RADIUS); // CGContextAddArcToPoint(ctx, p_1_0.x, p_1_0.y, p_1_0.x, p_1_0.y - CR_RADIUS*2, CR_RADIUS); CGContextClosePath(ctx); CGContextDrawPath(ctx, kCGPathFillStroke); 本文转自 卓行天下 51CTO博客,原文链接:http://blog.51cto.com/9951038/1772555,如需转载请自行联系原作者

优秀的个人博客,低调大师

ios13--购物车优化

// // ViewController.m // 03-综合练习 // #import "ViewController.h" @interface ViewController () // 购物车 @property (weak, nonatomic) IBOutlet UIView *shopCarView; // 添加按钮 @property (weak, nonatomic) IBOutlet UIButton *addButton; // 删除按钮 @property (weak, nonatomic) IBOutlet UIButton *removeButton; // 全局的下标 //@property (nonatomic, assign) NSInteger index; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; } /** * 添加到购物车 * * @param button 按钮 */ - (IBAction)add:(UIButton *)button { /***********************1.定义一些常量*****************************/ // 1.总列数 NSInteger allCols = 3; // 2.商品的宽度 和 高度 CGFloat width = 80; CGFloat height = 100; // 3.求出水平间距 和 垂直间距 CGFloat hMargin = (self.shopCarView.frame.size.width - allCols * width) / (allCols -1); CGFloat vMargin = (self.shopCarView.frame.size.height - 2 * height) / 1; // 4. 设置索引 NSInteger index = self.shopCarView.subviews.count; // 5.求出x值 CGFloat x = (hMargin + width) * (index % allCols); CGFloat y = (vMargin + height) * (index / allCols); /***********************2.创建一个商品*****************************/ // 1.创建商品的view UIView *shopView = [[UIView alloc] init]; // 2.设置frame shopView.frame = CGRectMake(x, y, width, height); // 3.设置背景颜色 shopView.backgroundColor = [UIColor greenColor]; // 4.添加到购物车 [self.shopCarView addSubview:shopView]; // 5.创建商品的UIImageView对象 UIImageView *iconView = [[UIImageView alloc] init]; iconView.frame = CGRectMake(0, 0, width, width); iconView.backgroundColor = [UIColor blueColor]; [shopView addSubview:iconView]; // 6.创建商品标题对象 UILabel *titleLabel = [[UILabel alloc] init]; titleLabel.frame = CGRectMake(0, width, width, height - width); titleLabel.backgroundColor = [UIColor yellowColor]; titleLabel.textAlignment = NSTextAlignmentCenter; // 居中 [shopView addSubview:titleLabel]; /***********************3.设置数据*****************************/ // 数值数据 /* // 方式一: (不可取:数据都是一样) iconView.image = [UIImage imageNamed:@"danjianbao"]; titleLabel.text = @"单肩包"; */ // 方式二 (不可取:太冗余) /* if (index == 0) { iconView.image = [UIImage imageNamed:@"danjianbao"]; titleLabel.text = @"单肩包"; }else if (index == 1){ iconView.image = [UIImage imageNamed:@"qianbao"]; titleLabel.text = @"钱包"; }else if (index == 2){ iconView.image = [UIImage imageNamed:@"danjianbao"]; titleLabel.text = @"单肩包"; }else if (index == 3){ iconView.image = [UIImage imageNamed:@"danjianbao"]; titleLabel.text = @"单肩包"; }else if (index == 4){ iconView.image = [UIImage imageNamed:@"danjianbao"]; titleLabel.text = @"单肩包"; }else if (index == 5){ iconView.image = [UIImage imageNamed:@"danjianbao"]; titleLabel.text = @"单肩包"; } */ // 方式三 (数组: (两个数组之间没有任何联系,容易出错)) /* NSArray<NSString *> *imageNames = @[@"danjianbao", @"qianbao", @"liantiaobao", @"shoutibao", @"shuangjianbao", @"xiekuabao"]; NSArray<NSString *> *titleNames = @[@"单肩包", @"钱包", @"链条包", @"手提包", @"双肩包", @"斜挎包"]; // 设置数据 iconView.image = [UIImage imageNamed:imageNames[index]]; titleLabel.text = titleNames[index]; */ // 方式四 (数组 + 字典) NSArray<NSDictionary *> *dataArr = @[ @{@"name":@"单肩包", @"icon":@"danjianbao"}, @{@"name":@"钱包", @"icon":@"qianbao"}, @{@"name":@"链条包", @"icon":@"liantiaobao"}, @{@"name":@"手提包", @"icon":@"shoutibao"}, @{@"name":@"双肩包", @"icon":@"shuangjianbao"}, @{@"name":@"斜挎包", @"icon":@"xiekuabao"} ]; // 设置数据 NSDictionary *dict = dataArr[index]; iconView.image = [UIImage imageNamed:dict[@"icon"]]; titleLabel.text = dict[@"name"]; /***********************4.设置按钮的状态*****************************/ button.enabled = (index != 5); // 5.设置删除按钮的状态 self.removeButton.enabled = YES; } /** * 从购物车中删除 * * @param button 按钮 */ - (IBAction)remove:(UIButton *)button { // 1. 删除最后一个商品 UIView *lastShopView = [self.shopCarView.subviews lastObject]; [lastShopView removeFromSuperview]; // 3. 设置添加按钮的状态 self.addButton.enabled = YES; // 4. 设置删除按钮的状态 /* if (self.shopCarView.subviews.count == 0) { self.removeButton.enabled = NO; } */ self.removeButton.enabled = (self.shopCarView.subviews.count != 0); } @end 本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/7449672.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

ios30---pthread, NSThread, GCD, NSOperation

pthread(线程库,很早就有的技术,了解): 一套通用的多线程API 适用于Unix\Linux\Windows等系统(java开发也有pthread) 跨平台\可移植 使用难度大(全是C函数) C语言 程序员管理线程生命周期,几乎不用 NSThread(掌握): 使用更加面向对象 简单易用,可直接操作线程对象 OC语言 程序员管理线程生命周期(管生不管死),偶尔使用 GCD(功能强大,重点): 旨在替代NSThread等线程技术 充分利用设备的多核(特点) c语言 自动管理线程生命周期,经常使用 NSOperation(重点): 基于GCD(底层是GCD) 比GCD多了一些更简单实用的功能 使用更加面向对象 OC语言 自动管理线程生命周期,经常使用 // // ViewController.m // 02-了解-pthread简单使用 // // Created by xiaomage on 16/2/18. // Copyright © 2016年 小码哥. All rights reserved. // #import "ViewController.h" #import <pthread.h> @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; } - (IBAction)btnClick:(id)sender { // NSLog(@"%@",[NSThread currentThread]); //1.创建线程对象,包含头文件#import <pthread.h> pthread_t thread; //2.创建线程函数 /* 第一个参数:线程对象 传递地址 第二个参数:线程的属性 NULL 第三个参数:指向函数的指针 第四个参数:函数需要接受的参数 */ pthread_create(&thread, NULL, task, NULL); // //1.创建线程对象 pthread_t threadB; // // //2.创建线程函数 // /* // 第一个参数:线程对象 传递地址 // 第二个参数:线程的属性 NULL // 第三个参数:指向函数的指针 // 第四个参数:函数需要接受的参数 // */ pthread_create(&threadB, NULL, task, NULL); pthread_equal(thread, threadB); } void* task(void* param) { for (NSInteger i = 0; i<2; i++) { NSLog(@"%zd----%@",i,[NSThread currentThread]); } NSLog(@"%@--------",[NSThread currentThread]); return NULL; } @end 本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/7488832.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS CAShapeLayer、CADisplayLink 实现波浪动画效果

效果图 代码已上传 GitHub:htt0p s : / / g i t hu b . c o m/ S il e n ce - G i t H u b /C o r e A n im a t i o n D em o 可以自定义波浪高度、宽度、速度、方向、渐变速度、水的深度等参数。 实现原理 波浪的形状绘制在 CAShapeLayer 上。通过 CADisplayLink 与屏幕刷新频率同步,每次刷新都绘制新的波浪,并改变小船的位置和角度。另外,水和天空的颜色是渐变的,由 CAGradientLayer 实现,其中,显示水的 CAGradientLayer 需要有波浪形状的 CAShapeLayer 的遮罩(mask)。 CAShapeLayer CAShapeLayer 的属性 path (CGPath)就是图层要显示的形状。把波浪的形状绘制出来,赋值给此属性即可。 CADisplayLink 创建 CADisplayLink,相应的 target 实现屏幕刷新时要调用的方法。把 CADisplayLink 加入 RunLoop 中。通过 isPaused 属性控制 CADisplayLink 是否暂停(target 是否调用方法) privatevarwaveLink:CADisplayLink? waveLink=CADisplayLink(target:self,selector:#selector(waveLinkRefresh)) waveLink?.isPaused=truewaveLink?.add(to:.current,forMode:.defaultRunLoopMode) 绘制波浪 波浪的形状关键是正弦函数曲线 y=A*sin(x+B) 参数 A 决定了波浪的高度;参数 B 决定了波浪在 x 轴的位置。 用一个属性 currentPhase 表示参数 B privatevarcurrentPhase:CGFloat=0 每次屏幕刷新的时候用 currentPhase 绘制,然后更新此属性,加上一个固定的数。这样波浪就会朝左或右匀速移动。 为了使波浪高度逐渐变化,用一个属性表示参数 A,然后每次绘制后更新此属性,加上一个固定的数,直到波浪高度达到目标值。 小船的位置和旋转角度 已知小船 x 轴坐标,通过正弦函数可以直接计算出小船的 y 轴坐标。此外,小船需要随着波浪旋转,旋转至船底与波浪表面相切。这就要对正弦函数进行求导 y'=A*cos(x+B) 用以上式子计算出小船所在位置的 y',表示正弦函数在此处的切线斜率,几何意义是切线与 x 轴的夹角的正切值。反正切即可求出切线与 x 轴的夹角,也就是小船需要旋转的角度 angle=atan(y') 用以上旋转角度,改变小船视图(UIView)的 transform,调用 CGAffineTransform 的 rotated(by:) 方法,实现小船的旋转。 CAGradientLayer CAGradientLayer 默认的颜色渐变方向是由上至下。给 colors 属性赋值一个包含 CGColor 的数组,则图层颜色由上至下,从数组第一个值经中间值渐变至最后一个值。 显示水的 CAGradientLayer 需要呈现波浪形状,需要 CAShapeLayer 的遮罩。把绘制好波浪形状的 CAShapeLayer 赋值给 CAGradientLayer 的 mask 属性即可。 以上是动画效果的实现原理,具体见 Git H u b:h t t ps : / / gi t h u b. c o m / S i l e nc e - G i tH u b / C or e A n im a t i o n De m o 转载请注明出处:ht tp :/ / w w w .c n b l og s .c o m /s i l en c e -c n b l og s /p / 6 97 9 4 1 8 .h t m l 本文转自xmgdc51CTO博客,原文链接:http://blog.51cto.com/12953214/1940544,如需转载请自行联系原作者

优秀的个人博客,低调大师

debian的ios下载及源设置

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 我的博客已迁移到xdoujiang.com请去那边和我交流 一、debian5-8的iso下载 1、cdimage.debian.org /cdimage/archive/5 .0.10 /amd64/iso-cd/debian-5010-amd64-CD-1 .iso 2、cdimage.debian.org /cdimage/archive/6 .0.10 /amd64/iso-cd/debian-6 .0.10-amd64-CD-1.iso 3、cdimage.debian.org /cdimage/archive/7 .9.0 /amd64/iso-cd/debian-7 .9.0-amd64-CD-1.iso 4、cdimage.debian.org /cdimage/archive/8 .1.0 /amd64/iso-cd/debian-8 .1.0-amd64-CD-1.iso 5、PS:这个地方有比较全的 cd 和dvd ftp : //mirrors .sohu.com 二、debian5-8源的设置 1、5(debian)源设置 deb ftp : //ftp .de.debian.org /debian-archive/debian/ lennymaincontribnon- free 2、6(debian)源设置 debhttp: //debian .ustc.edu.cn /debian/ squeezemaincontribnon- free deb-srchttp: //debian .ustc.edu.cn /debian/ squeezemaincontribnon- free debhttp: //debian .ustc.edu.cn /debian/ squeeze-updatesmaincontribnon- free deb-srchttp: //debian .ustc.edu.cn /debian/ squeeze-updatesmaincontribnon- free 3、7(debian)源设置 debhttp: //debian .ustc.edu.cn /debian/ wheezymaincontribnon- free deb-srchttp: //debian .ustc.edu.cn /debian/ wheezymaincontribnon- free debhttp: //debian .ustc.edu.cn /debian/ wheezy-updatesmaincontribnon- free deb-srchttp: //debian .ustc.edu.cn /debian/ wheezy-updatesmaincontribnon- free 4、8(debian)源设置 debhttp: //debian .ustc.edu.cn /debian/ jessiemaincontribnon- free deb-srchttp: //debian .ustc.edu.cn /debian/ jessiemaincontribnon- free debhttp: //debian .ustc.edu.cn /debian/ jessie-updatesmaincontribnon- free deb-srchttp: //debian .ustc.edu.cn /debian/ jessie-updatesmaincontribnon- free 三、debian版本 5Lenny2009年2月14日望远镜 6squeeze2011年2月16日三只眼睛的绿色大嘴玩具外星人 7wheezy2013年5月4日一只带着领结的玩具企鹅加强MultiArch稳定版本 8Jessie2015年4月26日玩具总动员第二部中的角色是一个女牛仔禁用了旧版不安全的SSLv3协议默认使用Systemd Sid每日更新席德,隔壁的男孩,玩具终结者软件较新,适合桌面和软件测试 本文转自 xdoujiang 51CTO博客,原文链接:http://blog.51cto.com/7938217/1660206,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码