UICollectionViewLayout 类

定义

用于指定 的布局的 UICollectionView基类。

[Foundation.Register("UICollectionViewLayout", true)]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public class UICollectionViewLayout : Foundation.NSObject, Foundation.INSCoding, IDisposable
type UICollectionViewLayout = class
    inherit NSObject
    interface INSCoding
    interface INativeObject
    interface IDisposable
继承
UICollectionViewLayout
派生
属性
实现

注解

集合视图允许使用任意布局显示内容。 类似网格的布局可以使用 UICollectionViewFlowLayout 或 应用程序开发人员可以子类型 UICollectionViewLayout 来创建自己的灵活模式。

UICollectionView 的布局由 UICollectionViewLayout控制,该布局UICollectionViewCell可以传递到 C:UIKit.UICollectionView (UICollectionViewLayout) 构造函数更改SetCollectionViewLayout

应用程序开发人员可以通过对 或 UICollectionViewLayout进行子类化UICollectionViewFlowLayout来创建完全自定义布局。

要替代的关键方法是:

方法说明
PrepareLayout() 用于执行将在整个布局过程中使用的初始几何计算。
CollectionViewContentSize 返回用于显示内容的区域的大小。
LayoutAttributesForElementsInRect(CGRect) 返回指定矩形内所有单元格和视图的布局属性。
LayoutAttributesForItem(NSIndexPath) 特定单元格的布局属性
ShouldInvalidateLayoutForBoundsChange(CGRect) true如果新边界需要更新布局,则返回 。

以下代码取自“集合视图简介”类,创建一个圆形布局,如下图所示:

public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath path)
{
  UICollectionViewLayoutAttributes attributes = UICollectionViewLayoutAttributes.CreateForCell (path);
  attributes.Size = new SizeF (ItemSize, ItemSize);

  attributes.Center = new PointF (center.X + radius * (float)Math.Cos (2 * path.Row * Math.PI / cellCount),
    center.Y + radius * (float)Math.Sin (2 * path.Row * Math.PI / cellCount));
  return attributes;
}

构造函数

UICollectionViewLayout()

默认构造函数初始化此类的新实例。

UICollectionViewLayout(IntPtr)

创建非托管对象的托管表示形式时使用的构造函数;由运行时调用。

UICollectionViewLayout(NSCoder)

从 unarchiver 对象中存储的数据初始化 对象的构造函数。

UICollectionViewLayout(NSObjectFlag)

用于调用派生类的构造函数,以跳过初始化并仅分配 对象。

属性

Class

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
ClassHandle

此类的句柄。

CollectionView

UICollectionViewUICollectionViewLayout布局的 。

CollectionViewContentSize

此 UICollectionViewLayout 内容的 SizeF。

DebugDescription

此对象的开发人员有意义的说明。

(继承自 NSObject)
Description

对象的说明,即 ToString 的 Objective-C 版本。

(继承自 NSObject)
DevelopmentLayoutDirection

获取开发期间使用的语言方向。

FlipsHorizontallyInOppositeLayoutDirection

获取一个布尔值,该值指示坐标系是否针对反向布局方向水平反转。

Handle

处理指向非托管对象表示形式的 (指针) 。

(继承自 NSObject)
IsDirectBinding

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
IsProxy

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
LayoutAttributesClass

用于此 UICollectionViewLayout 布局属性的 UICollectionViewLayoutAttributes。

RetainCount

返回对象的当前 Objective-C 保留计数。

(继承自 NSObject)
Self

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
Superclass

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
SuperHandle

用于表示此 NSObject 基类中方法的句柄。

(继承自 NSObject)
Zone

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)

方法

AddObserver(NSObject, NSString, NSKeyValueObservingOptions, IntPtr)

使用 NSString keyPath) 注册在外部 (观察到的对象。   观察到的更改将调度到观察者的 对象 ObserveValue(NSString, NSObject, NSDictionary, IntPtr) 方法。

(继承自 NSObject)
AddObserver(NSObject, String, NSKeyValueObservingOptions, IntPtr)

使用 string keyPath) 注册在外部 (观察到的对象。   观察到的更改将调度到观察者的 对象 ObserveValue(NSString, NSObject, NSDictionary, IntPtr) 方法。

(继承自 NSObject)
AddObserver(NSString, NSKeyValueObservingOptions, Action<NSObservedChange>)

注册一个对象,以便使用任意方法在外部观察到。

(继承自 NSObject)
AddObserver(String, NSKeyValueObservingOptions, Action<NSObservedChange>)

注册一个对象,以便使用任意方法在外部观察到。

(继承自 NSObject)
AwakeFromNib()

从 nib 文件加载对象后调用。 重写程序必须调用 base。AwakeFromNib () 。

(继承自 NSObject)
BeginInvokeOnMainThread(Action)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
BeginInvokeOnMainThread(Selector, NSObject)

在主 UI 线程上异步调用指定的代码。

(继承自 NSObject)
Bind(NSString, NSObject, String, NSDictionary)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
Bind(String, NSObject, String, NSDictionary)
已过时.

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
BindingInfo(String)
已过时.

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
BindingOptionDescriptions(String)
已过时.

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
BindingValueClass(String)
已过时.

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
CommitEditing()

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
CommitEditing(NSObject, Selector, IntPtr)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
ConformsToProtocol(IntPtr)

调用 以确定此对象是否实现指定的协议。

(继承自 NSObject)
Copy()

执行基础 Objective-C 对象的副本。

(继承自 NSObject)
DangerousAutorelease()

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
DangerousRelease()

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
DangerousRetain()

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
DidChange(NSKeyValueChange, NSIndexSet, NSString)

指示对多关系的索引发生了更改。

(继承自 NSObject)
DidChange(NSString, NSKeyValueSetMutationKind, NSSet)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
DidChangeValue(String)

指示在指定的键上发生了更改。

(继承自 NSObject)
Dispose()

释放 NSObject 对象使用的资源。

(继承自 NSObject)
Dispose(Boolean)

释放 NSObject 对象使用的资源。

(继承自 NSObject)
DoesNotRecognizeSelector(Selector)

指示此对象无法识别指定的选择器。

(继承自 NSObject)
EncodeTo(NSCoder)

在提供的编码器上对对象的状态进行编码

Equals(NSObject)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
Equals(Object)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
ExposedBindings()

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
FinalizeAnimatedBoundsChange()

重写时,在对边界进行动画更改或插入或删除项后执行自定义清理。

FinalizeCollectionViewUpdates()

重写时,允许在更新期间进行其他动画或清理。

FinalizeLayoutTransition()

在切换动画之前调用,通知布局对象在动画之前执行任何必要的步骤。

FinalLayoutAttributesForDisappearingDecorationElement(NSString, NSIndexPath)

即将从此 UICollectionViewLayout 中删除的修饰元素的最终布局信息。

FinalLayoutAttributesForDisappearingItem(NSIndexPath)

即将从 UICollectionView 中删除的项的最终布局信息。

FinalLayoutAttributesForDisappearingSupplementaryElement(NSString, NSIndexPath)

即将从集合视图中删除的补充视图的最终布局信息。

GetBindingInfo(NSString)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
GetBindingOptionDescriptions(NSString)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
GetBindingValueClass(NSString)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
GetDictionaryOfValuesFromKeys(NSString[])

检索指定键的值。

(继承自 NSObject)
GetHashCode()

为当前实例生成哈希代码。

(继承自 NSObject)
GetIndexPathsToDeleteForDecorationViewOfKind(NSString)

NSIndexPaths 数组,指示要删除的修饰视图。

GetIndexPathsToDeleteForSupplementaryView(NSString)

NSIndexPaths 的数组,指示要删除的补充视图。

GetIndexPathsToInsertForDecorationView(NSString)

NSIndexPaths 数组,指示要添加的修饰视图。

GetIndexPathsToInsertForSupplementaryView(NSString)

指示要添加的补充视图的索引路径数组。

GetInvalidationContext(UICollectionViewLayoutAttributes, UICollectionViewLayoutAttributes)

获取从 originalAttributes 更改为 preferredAttributes的无效区域。

GetInvalidationContextForBoundsChange(CGRect)

返回一个 UICollectionViewLayoutInvalidationContext,它指定为响应边界更改而更改的布局部分。

GetInvalidationContextForEndingInteractiveMovementOfItems(NSIndexPath[], NSIndexPath[], Boolean)

返回移动项的验证上下文。

GetInvalidationContextForInteractivelyMovingItems(NSIndexPath[], CGPoint, NSIndexPath[], CGPoint)

获取一个 UICollectionViewLayoutInvalidationContext ,它标识要移动的项。

GetLayoutAttributesForInteractivelyMovingItem(NSIndexPath, CGPoint)

返回用户正在移动的项的布局属性。

GetMethodForSelector(Selector)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
GetNativeField(String)
已过时.

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
GetNativeHash()

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
GetTargetIndexPathForInteractivelyMovingItem(NSIndexPath, CGPoint)

返回用户正在移动的项的目标索引路径。

Init()

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
InitializeHandle(IntPtr)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
InitializeHandle(IntPtr, String)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
InitialLayoutAttributesForAppearingDecorationElement(NSString, NSIndexPath)

有关要插入 UICollectionView 的装饰视图的起始布局的信息。

InitialLayoutAttributesForAppearingItem(NSIndexPath)

有关要插入到 UICollectionView 中的项的起始布局的信息。

InitialLayoutAttributesForAppearingSupplementaryElement(NSString, NSIndexPath)

有关正在插入 UICollectionView 的补充视图的起始布局的信息。

InvalidateLayout()

使当前布局失效并启动更新。

InvalidateLayout(UICollectionViewLayoutInvalidationContext)

强制重新计算和应用集合视图。

InvalidationContextClass()

用于此 UICollectionViewLayout 的自定义 UICollectionViewLayoutInvalidationContext。

Invoke(Action, Double)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
Invoke(Action, TimeSpan)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
InvokeOnMainThread(Action)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
InvokeOnMainThread(Selector, NSObject)

在主 UI 线程上同步调用指定的代码。

(继承自 NSObject)
IsEqual(NSObject)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
IsKindOfClass(Class)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
IsMemberOfClass(Class)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
LayoutAttributesForDecorationView(NSString, NSIndexPath)

指定修饰视图的 UICollectionViewLayoutAttributes。

LayoutAttributesForElementsInRect(CGRect)

指定 RectangleF中的所有单元格和视图的 UICollectionViewLayoutAttributes。

LayoutAttributesForItem(NSIndexPath)

指定 NSIndexPath 的 UICollectionViewLayoutAttributes。

LayoutAttributesForSupplementaryView(NSString, NSIndexPath)

指定补充视图的 UICollectionViewLayoutAttributes。

LayoutAttributesForSupplementaryView(UICollectionElementKindSection, NSIndexPath)

指定 indexPath 处的补充视图的属性。

MarkDirty()

将常规对等对象 (IsDirectBinding 为 true) 提升为 toggleref 对象。

(继承自 NSObject)
MutableCopy()

创建指定 NSObject 的可变副本。

(继承自 NSObject)
ObjectDidEndEditing(NSObject)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
ObserveValue(NSString, NSObject, NSDictionary, IntPtr)

指示指定 keyPath 相对于此对象的值已更改。

(继承自 NSObject)
PerformSelector(Selector)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
PerformSelector(Selector, NSObject)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
PerformSelector(Selector, NSObject, Double)

在当前实例上调用选择器,如果 obj 不为 null,则将其作为单个参数传递。

(继承自 NSObject)
PerformSelector(Selector, NSObject, Double, NSString[])

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
PerformSelector(Selector, NSObject, NSObject)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean, NSString[])

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
PrepareForAnimatedBoundsChange(CGRect)

在对边界进行动画更改之前或插入或删除项之前调用。

PrepareForCollectionViewUpdates(UICollectionViewUpdateItem[])

通知布局对象 UICollectionView 的内容即将更改。

PrepareForInterfaceBuilder()

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
PrepareForTransitionFromLayout(UICollectionViewLayout)

通知布局对象,它将很快安装为 UICollectionView 的布局。

PrepareForTransitionToLayout(UICollectionViewLayout)

告知布局对象,它将很快作为 UICollectionView 的布局删除。

PrepareLayout()

告知布局对象更新布局。

RegisterClassForDecorationView(Type, NSString)

将按种类标识的类注册为修饰视图。

RegisterNibForDecorationView(UINib, NSString)

注册 UINib 以用作装饰视图的模板。

RemoveObserver(NSObject, NSString)

阻止指定的观察程序接收指定 keyPath 的更改值的进一步通知。

(继承自 NSObject)
RemoveObserver(NSObject, NSString, IntPtr)

阻止指定的观察程序接收指定 keyPath 和上下文的更改值的进一步通知。

(继承自 NSObject)
RemoveObserver(NSObject, String)

阻止指定的观察程序接收指定 keyPath 的更改值的进一步通知。

(继承自 NSObject)
RemoveObserver(NSObject, String, IntPtr)

阻止指定的观察程序接收指定 keyPath 和上下文的更改值的进一步通知。

(继承自 NSObject)
RespondsToSelector(Selector)

此对象是否识别指定的选择器。

(继承自 NSObject)
SetNativeField(String, NSObject)
已过时.

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
SetNilValueForKey(NSString)

将指定键的值设置为 null。

(继承自 NSObject)
SetValueForKey(NSObject, NSString)

将键指定的属性的值设置为指定值。

(继承自 NSObject)
SetValueForKeyPath(IntPtr, NSString)

创建非托管对象的托管表示形式时使用的构造函数;由运行时调用。

(继承自 NSObject)
SetValueForKeyPath(NSObject, NSString)

设置可使用键路径访问的属性的值。

(继承自 NSObject)
SetValueForUndefinedKey(NSObject, NSString)

指示尝试将值写入未定义的键。 如果未重写,则引发 NSUndefinedKeyException。

(继承自 NSObject)
SetValuesForKeysWithDictionary(NSDictionary)

将此 NSObject 的值设置为指定字典中的值。

(继承自 NSObject)
ShouldInvalidateLayout(UICollectionViewLayoutAttributes, UICollectionViewLayoutAttributes)

如果集合视图需要使从 preferredAttributes 更改为 originalAttributes的更改无效,则返回 true。

ShouldInvalidateLayoutForBoundsChange(CGRect)

新边界是否需要布局更新。

TargetContentOffset(CGPoint, CGPoint)

停止滚动的 PointF。

TargetContentOffsetForProposedContentOffset(CGPoint)

动画布局更改后要使用的内容偏移量。

ToString()

返回当前实例值的字符串表示形式。

(继承自 NSObject)
Unbind(NSString)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
Unbind(String)
已过时.

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
ValueForKey(NSString)

返回与指定键关联的属性的值。

(继承自 NSObject)
ValueForKeyPath(NSString)

返回可使用键路径访问的属性的值。

(继承自 NSObject)
ValueForUndefinedKey(NSString)

指示尝试读取未定义键的值。 如果未重写,则引发 NSUndefinedKeyException。

(继承自 NSObject)
WillChange(NSKeyValueChange, NSIndexSet, NSString)

指示指定键中指定索引的值即将更改。

(继承自 NSObject)
WillChange(NSString, NSKeyValueSetMutationKind, NSSet)

用于指定 的布局的 UICollectionView基类。

(继承自 NSObject)
WillChangeValue(String)

指示指定键的值即将更改。

(继承自 NSObject)

扩展方法

GetDebugDescription(INSObjectProtocol)

用于指定 的布局的 UICollectionView基类。

GetAccessibilityCustomRotors(NSObject)

获取适用于 this 对象的 对象的数组UIAccessibilityCustomRotor

SetAccessibilityCustomRotors(NSObject, UIAccessibilityCustomRotor[])

设置适用于 this 对象的 对象数组UIAccessibilityCustomRotor

适用于

另请参阅