zoukankan      html  css  js  c++  java
  • UI Core CollectionView

    Text Kit学习(入门和进阶)

     Core Image Programming Guide--图像编程指南 

    CollectionView 添加/删除动画

    UICollectionViewFlowLayout自定义  goods 写日历

    -(CGSize)collectionViewContentSize

    -(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds

    - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)path{}//返回每个cell的布局属性

    -(NSArray*)layoutAttributesForElementsInRect:(CGRect)rect //返回所有cell的布局属性

     关于自定义UICollectionViewLayout的一点个人理解

    自定义UICollectionView,主要会用到以下几个方法:

    - (void)prepareLayout; 第一次加载layout、刷新layout、以及- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds;这个方法返回yes时,会调用。这是苹果官方的说明The collection view calls -prepareLayout once at its first layout as the first message to the layout instance. The collection view calls -prepareLayout again after layout is invalidated and before requerying the layout information. Subclasses should always call super if they override。实现该方法后应该调用[super prepareLayout]保证初始化正确。该方法用来准备一些布局所需要的信息。该方法和init方法相似,但该方法可能会被调用多次,所以一些不固定的计算(比如该计算和collectionView的尺寸相关),最好放在这里,以保证collectionView发生变化时,自定义CollectionView能做出正确的反应。                                                                                                                                                                                                                                                                                              
    - (nullable NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect; 该方法用来返回rect范围内的 cell supplementary 以及 decoration的布局属性layoutAttributes(这里保存着她们的尺寸,位置,indexPath等等),如果你的布局都在一个屏幕内 活着 没有复杂的计算,我觉得这里可以返回全部的属性数组,如果涉及到复杂计算,应该进行判断,返回区域内的属性数组,有时候为了方便直接返回了全部的属性数组,不影响布局但可能会影响性能(如果你的item一屏幕显示不完,那么这个方法会调用多次,当所有的item都加载完毕后,在滑动collectionView时不会调用该方法的)。                                                                                                                                                                                                                                   
    - (nullable UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath; 该方法不是必须实现的,即便你实现了,我们对collectionView的任何操作,也不会导致系统主动调用该方法。该方法通常用来定制某个IndexPath的item的属性。当然我们也可以重写这个方法,将布局时相关的属性设置放在这里,在- (nullable NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect 或者 - (void)prepareLayout 中 需要创建用来返回给系统的属性数组 主动调用这个方法,并添加带可变数组中去返回给系统。当然我们也可以在 - (void)prepareLayout 中 通过[UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:[NSIndexPath indexPathForRow:i inSection:0]] 获取 每个indexPath的attributes,在- (void)prepareLayout中设置所有item的属性。看需求以及个人喜欢。                                                                                                                                                         
    - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds; 用来刷新layout的,当我们返回yes的时候。如果我们的需求不需要实时的刷新layout,那么最好判断newBounds 和 我们的collectionView的bounds是否相同,不同时返回yes;(例如苹果官方的lineLayout,因为每次滑动都要放大item,所以这了就直接返回yes)。

    UIKit Framework Reference

    iOS文字排版(CoreText)那些事儿

    iOS 7系列译文:认识 TextKit

    关于UIWebView的一些事

    Collection View 动画

    Collection View Programming Guide for iOS

    更轻量的 View Controllers

    自定义 Collection View 布局

    iOS 8自动调整UITableView和UICollectionView布局

    iOS开发者如何提高自己的水平?

    iOS中图形图像处理第一部分:位图图像原图修改

    The Death of Cocoa

    Objective-C Runtime

    刨根问底Objective-C Runtime(1)- Self & Super

    刨根问底Objective-C Runtime(2)- Object & Class & Meta Class

     调试:案例学习

    代码签名探析

     SizeClasss和AutoLayout教程4

     WWDC2014观感兼回答iOS初学者的困惑

    一个程序猿至少要掌握三类编程语言,精通其中的1-2种。
     
    1.系统级语言
    C,C++
     
    2.普适性语言
    Java, C#,Objective-C
     
    3.脚本语言
    javascript,PHP,Python,Ruby,Perl
     
  • 相关阅读:
    android SQLiteDatabase数据库使用的时候 常见问题
    ArrayList与LinkedList的基本添加删除方法 模拟栈 队列
    ImageView小技巧
    TextView 小技巧
    悬浮窗
    帧动画布局文件 animation-list
    VideoView的全屏问题
    FragmentPagerAdapter与FragmentStatePagerAdapter区别
    观察者模式 DataObserver
    vue中filter的用法
  • 原文地址:https://www.cnblogs.com/dqxu/p/4292872.html
Copyright © 2011-2022 走看看