iOS学习—UI部分
学习笔记666
这个作者很懒,什么都没留下…
展开
-
自定义UICollectionViewFlowLayout
1.自定义一个继承自UICollectionViewFlowLayout的类//// LineLayout.h// 自定义UICellectionView布局//#import @interface LineLayout : UICollectionViewFlowLayout@end//// LineLayout.m// 自定义UICellectionVie原创 2016-01-04 20:00:59 · 988 阅读 · 1 评论 -
自定义UICollectionViewLayout
扎堆布局效果//// StackLayout.h// 自定义UICellectionView布局#import @interface StackLayout : UICollectionViewLayout@end//// StackLayout.m// 自定义UICellectionView布局#import "StackLayout.h"@i原创 2016-01-04 20:26:23 · 478 阅读 · 0 评论 -
自定义UICollectionViewLayout(原形环绕效果)
//// CircleLayout.h// 自定义UICellectionView布局#import @interface CircleLayout : UICollectionViewLayout@end//// CircleLayout.m// 自定义UICellectionView布局#import "CircleLayout.h"@implemen原创 2016-01-04 20:30:30 · 575 阅读 · 0 评论 -
自定义UICollectionViewLayout—实现瀑布流效果
最终效果:用到的第三方框架:1.自定义UICollectionViewLayout实现瀑布流布局效果//// WaterflowLayout.h// 0104-瀑布流#import @class WaterflowLayout;@protocol WaterflowLayoutDelegate - (CGFloat)waterflowLayout原创 2016-01-05 21:04:58 · 652 阅读 · 0 评论 -
Autolayout自动布局1
需求:控件宽300高100,距离底部10,距离右边10最终效果如图: // 1.创建控件 UIView *blueView = [[UIView alloc] init]; [self.view addSubview:blueView]; blueView.backgroundColor = [UIColor blueColor]; //不要将原创 2016-01-27 20:27:36 · 284 阅读 · 0 评论 -
Autolayout自动布局2
需求:控件水平居中,垂直居中,宽度高度均为父控件的一半 // 1.创建控件 UIView *blueView = [[UIView alloc] init]; [self.view addSubview:blueView]; blueView.backgroundColor = [UIColor blueColor]; //不要将Autor原创 2016-01-27 20:39:48 · 330 阅读 · 0 评论 -
Autolayout自动布局3
UIView *blueView = [[UIView alloc] init]; [self.view addSubview:blueView]; blueView.backgroundColor = [UIColor blueColor]; //不要将AutoresizingMask转为Autolayout的约束 blueView.translatesAutor原创 2016-01-27 20:56:31 · 375 阅读 · 0 评论 -
Visual format language(1)
需求:添加一个控件,高度40,距离顶部,左边,右边 20 // 1.创建控件 UIView *blueView = [[UIView alloc] init]; [self.view addSubview:blueView]; blueView.backgroundColor = [UIColor blueColor]; //不要将Autoresizing原创 2016-01-27 21:17:55 · 418 阅读 · 0 评论 -
Visual format language(2)
需求:2个控件,宽度相等,间距为20,距离左边右边为20,高度相等为40 // 1.创建控件 UIView *blueView = [[UIView alloc] init]; [self.view addSubview:blueView]; blueView.backgroundColor = [UIColor blueColor]; //不要将原创 2016-01-27 21:29:16 · 345 阅读 · 0 评论 -
run loop
一个GUI应用程序开始执行之后,就会不断的执行一个环圈,知道用户决定要关闭这个应用程序的时候,才会关闭这个环圈。这样的环圈在Windows平台上叫做message loop,在iOS平台与Mac OS X 上叫做 run loop,而这个月环圈当做所做的就是收取与分派事件。Timer也是依靠run loop运行的。当我们建立了一个NSTimer对象之后,下一步就是要把timer对象注册原创 2016-01-28 14:26:59 · 386 阅读 · 0 评论 -
UIView于CALayer的主要的关系
我们应该都知道每个UIView都包含了一个CALayer。比如给一个View切个圆角:view.layer.cornerRadius = 5.0f;//加个边框view.layer.borderWidth = 1.0f;view.layer.borderColor = [UIColor redColor].CGColor;CALayer是QuartzCore库内的类,是iOS上最基本的绘转载 2016-01-11 10:20:00 · 413 阅读 · 0 评论 -
自定义等高的cell(代码创建frame)
//// tgCell.h#import @class tgModel;@interface tgCell : UITableViewCell/** * 团购模型数据 */@property(nonatomic,strong)tgModel *model;/** * 创建一个cell */+ (instancetype)cellWithTableView:(原创 2016-02-05 20:04:20 · 435 阅读 · 0 评论 -
自定义等高的cell(代码Autolayout)
//// tgCell.m#import "tgCell.h"#import "tgModel.h"//define this constant if you want to use Masonry without the 'mas_' prefix#define MAS_SHORTHAND//define this constant if you want to enable原创 2016-02-05 20:14:10 · 294 阅读 · 0 评论 -
xib自定义非等高的cell
/* 1.在模型中增加一个 cellHeight属性,用来存放对于cell的高度 2.在cell的模型属性的set方法中调用[self layoutIfNeed]方法强制布局,然后计算出cellHeight的值 3.控制器中实现tableView:estimatedHeightForRowAtIndexPath方法,返回一个cell的估计高度,比如200 4.控制器中实现tableView转载 2016-02-05 22:28:46 · 444 阅读 · 0 评论 -
storyboard自定义非等高的Cell
//// WeiboCell.m#import "WeiboCell.h"#import "WeiboModel.h"@interface WeiboCell()@property (weak, nonatomic) IBOutlet UIImageView *iconView;@property (weak, nonatomic) IBOutlet UILabel *name原创 2016-02-06 09:57:22 · 355 阅读 · 0 评论 -
UITableViewCell上左滑删除
//// TableViewController.m#import "TableViewController.h"#import "tgModel.h"#import "tgCell.h"@interface TableViewController ()/** 所有团购数据 */@property(nonatomic,strong) NSMutableArray *tgs;原创 2016-02-06 11:47:03 · 385 阅读 · 0 评论 -
UIAlertController
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"标题" message:@"2222" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; [alertView show]; //iOS8以后 UIAlertContr原创 2016-02-06 15:40:29 · 373 阅读 · 0 评论 -
0206-UITableView上的批量操作(自定义)
1.在模型添加一个标识 打钩的属性/** 状态量标识有没有被打钩 */@property(nonatomic,assign,getter=isChecked)BOOL checked;//// tgModel.h#import @interface tgModel : NSObject//注意这里用的是 strong@property(nonatomic,st原创 2016-02-06 17:24:14 · 347 阅读 · 0 评论 -
简单是换肤示例
1.抽取的工具类//// SkinTool.h#import @interface SkinTool : NSObject+ (void)setSKinColor:(NSString *)skinColor;+ (UIImage *)skinToolWithImageName:(NSString *)imageName;+ (UIColor *)skinToolWit转载 2016-02-07 22:18:21 · 336 阅读 · 0 评论 -
Core Animation 之 CALayer
Core Animation 是在iOS上负责一般UI绘图和动画的框架。真的要详细介绍Core Animation,都可以写一本书,我们这边尽量简短介绍。Core Animation大概分成3种主要的class;CALayerCAAnimationCATransaction1. CALayer与UIView的关系任何一个view都有2种性质组成的,可以操作和可以被看到。原创 2016-01-29 16:06:28 · 433 阅读 · 0 评论 -
Core Animation 之 CATransaction
CATransaction 在 Core Animation framework中主要扮演了“整体舞台设定的角色”。使用 CATransaction 的方式就是把我们想做的特别的设定的动画代码,用 CATransaction 的class method前后包起来。比方说,我们现在不希望产生动画,便可以这样写:[CATransaction begin];[CATransaction set原创 2016-01-29 16:20:21 · 517 阅读 · 0 评论 -
自定义控制器切换
1.先添加一个view(菜单栏)并添加约束2.再往 菜单栏view中,添加3个按钮控件,等高等宽3.让菜单栏中3个按钮都连线到控制器的buttonclick方法上,并创建3个控制器4.父控制代码//// ViewController.m#import "ViewController.h"#import "OneViewController.h"原创 2016-02-09 17:54:18 · 492 阅读 · 0 评论 -
自定义控制器的切换-动画
效果://// ViewController.m// 0209-自定义控制器的切换//// Created by yongkaidong on 16/2/9.// Copyright © 2016年 com.yongkaidong. All rights reserved.//#import "ViewController.h"#import "OneViewCont原创 2016-02-09 18:07:00 · 317 阅读 · 0 评论 -
级联菜单(方式一)
1.创建2个子控制器,加到当前控制器#import "ViewController.h"#import "CategoryViewController.h"#import "SubcategoryViewController.h"@interface ViewController ()@end@implementation ViewController- (void)vie原创 2016-02-10 11:10:50 · 4782 阅读 · 0 评论 -
级联菜单(2个tableView共用一个数据源的方式)
1.在storyboard里拖2个UITabelView,并把deletegate和dataSoure属性连线到当前控制器。设置2个tableView的cell的标识。布局添加约束,2个tableView等高等宽。//// ViewController.m#import "ViewController.h"#import "CategoryModel.h"@in原创 2016-02-10 12:00:30 · 1435 阅读 · 0 评论 -
Masonry的使用1
#import "ViewController.h"#import "Masonry.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // 1.创建控件 UIView *blueView =原创 2016-01-29 21:51:04 · 360 阅读 · 0 评论 -
Masonry的使用2
//居中,尺寸是父控件的一半 [blueView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(self.view).multipliedBy(0.5); make.center.mas_equalTo(self.view); }]; //内边距,距离父原创 2016-01-29 22:01:46 · 505 阅读 · 0 评论 -
Masonry的使用3
1.#import "ViewController.h"//只要添加了这个宏,就不用带 mas_前缀#define MAS_SHORTHAND//只要添加了这个宏,equalTo就等价于mas_equalTo#define MAS_SHORTHAND_GLOBALS//这个头文件一定要放在前面2个宏的后面#import "Masonry.h"2.- (void)viewDidLoad原创 2016-01-29 22:17:07 · 401 阅读 · 0 评论 -
网易新闻首页demo
1.在storyboard里拖2个scrollView,一个用来显示上面的菜单标题,一个用来显示对应的内容2.父控制器里添加子控制器//// ViewController.m#import "ViewController.h"#import "NewsViewController.h"#import "HomeLabel.h"@interface ViewCont原创 2016-02-10 22:21:03 · 608 阅读 · 0 评论 -
UIScrollView常见功能(scrollView里子控件悬停)
//// ViewController.m#import "ViewController.h"@interface ViewController ()@property(nonatomic,weak)UIScrollView *scrollView;@property(nonatomic,weak)UIImageView *imageView;@property(nonatom原创 2016-02-11 14:08:12 · 3126 阅读 · 2 评论 -
UIScrollView内部子控件自动布局的一些注意点
/** UIScrollView内部子控件添加约束的注意点: 1.子控件的尺寸不能通过UIScrollView来计算,可以考虑通过以下方式计算 * 可以设置固定值(width==100,height==300) * 可以相对于UIScrollView以外的其他控件来计算尺寸 2.UIScrollView的frame应该通过子控件以外的其他控件来计算 3.UIScrollVi转载 2016-02-11 15:57:54 · 1764 阅读 · 0 评论 -
模仿modal效果
1.准备2个控制器2.//// ViewController.m#import "ViewController.h"#import "TwoViewController.h"@interface ViewController ()/** * 注意这里是强引用 */@property(nonatomic,strong)UIViewController *原创 2016-03-03 20:40:08 · 346 阅读 · 0 评论 -
UIView的拖拽
1.2.//// RedView.m#import "RedView.h"@implementation RedView/** * 当手指在View上移动就会调用 */-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ // 取出UITouch对象 UITouch原创 2016-03-03 21:15:11 · 905 阅读 · 0 评论 -
UITableViewCell的循环利用
#import "ViewController.h"@interface ViewController () @end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //初始化一个tableView UITableView *tableView = [[UIT原创 2016-02-03 20:09:34 · 355 阅读 · 0 评论 -
UITableViewCell的循环利用 - 在storyboard里
#import "TableViewController.h"@interface TableViewController ()@end@implementation TableViewController- (void)viewDidLoad { [super viewDidLoad];}#pragma mark - Table view data source原创 2016-02-03 22:22:52 · 485 阅读 · 0 评论 -
自定义等高的cell(storyboard)
/* storyboard自定义cell 1.创建一个继承自UITabelViewCell的子类,比如tgCell 2.在storyboard中: 往cell里面增加需要用到的子控件; 设置cell的重用标识; 设置cell的class为tgCell 3.在控制器中: 利用重用标识找到cell; 给cell传递模型数据 4.在tgCell中:原创 2016-02-04 22:09:39 · 413 阅读 · 0 评论 -
自定义等高的cell(xib)
/* xib自定义cell 1.创建一个继承自UITabelViewCell的子类,比如tgCell 2.创建一个xib文件(文件名建议跟cell的类名一样),比如tgCell.xib 拖一个UITabelViewCell控件; 修改cell的class属性为tgCell; 设置重用标识; 往cell中添加需要的子控件 3.在控制器中 创建cell;原创 2016-02-04 23:11:30 · 336 阅读 · 0 评论 -
状态栏前景色改为白色的几种方法
1.AppDelegate.m 全局配置- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 全局设置状态栏前景色为白色 [[UIApplication sharedApplication] setStatus原创 2016-03-04 14:56:18 · 1393 阅读 · 0 评论 -
自定义的导航控制中设置保留系统默认的透明传统效果
#import "MyNavigationController.h"@interface MyNavigationController ()@end@implementation MyNavigationController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup af原创 2016-03-04 15:36:17 · 369 阅读 · 0 评论 -
导航栏上文字颜色的设置
#import "MyNavigationController.h"@interface MyNavigationController ()@end@implementation MyNavigationController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup af原创 2016-03-04 15:45:08 · 2684 阅读 · 0 评论