UIView全部API的翻譯(2)

? ? ? ? ? ? ? ? UIView全部API的翻譯(2)

接著上一篇,繼續(xù)寫(好長啊!):

@interface UIView(UIViewAnimationWithBlocks)

block封裝參與動(dòng)畫,動(dòng)畫時(shí)長,延遲時(shí)間,動(dòng)畫選項(xiàng)條件 動(dòng)畫結(jié)束的回調(diào)

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);

block封裝參與動(dòng)畫,動(dòng)畫時(shí)長,動(dòng)畫結(jié)束的回調(diào)

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0

block封裝參與動(dòng)畫,動(dòng)畫時(shí)長

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0, completion = NULL

/* Performs `animations` using a timing curve described by the motion of a spring. When `dampingRatio` is 1, the animation will smoothly decelerate to its final model values without oscillating. Damping ratios less than 1 will oscillate more and more before coming to a complete stop. You can use the initial spring velocity to specify how fast the object at the end of the simulated spring was moving before it was attached. It's a unit coordinate system, where 1 is defined as travelling the total animation distance in a second. So if you're changing an object's position by 200pt in this animation, and you want the animation to behave as if the object was moving at 100pt/s before the animation started, you'd pass 0.5. You'll typically want to pass 0 for the velocity. */

block封裝參與動(dòng)畫持續(xù)的時(shí)間,動(dòng)畫效果

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);

轉(zhuǎn)場動(dòng)畫

+ (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);

+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); // toView added to fromView.superview, fromView removed from its superview

/* Performs the requested system-provided animation on one or more views. Specify addtional animations in the parallelAnimations block. These additional animations will run alongside the system animation with the same timing and duration that the system animation defines/inherits. Additional animations should not modify properties of the view on which the system animation is being performed. Not all system animations honor all available options.

*/

+ (void)performSystemAnimation:(UISystemAnimation)animation onViews:(NSArray<__kindof UIView *> *)views options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))parallelAnimations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);

@end

UIView的關(guān)鍵幀動(dòng)畫

@interface UIView (UIViewKeyframeAnimations)

UIView添加了一個(gè)方法用來直接使用關(guān)鍵幀動(dòng)畫而不用輔助CoreAnimation來實(shí)現(xiàn)号杏,這個(gè)方法需要浮點(diǎn)型的動(dòng)畫持續(xù)時(shí)長和延遲衔肢,一些二進(jìn)制組成的選項(xiàng)和動(dòng)畫運(yùn)行的block和動(dòng)畫運(yùn)行完后最后的block咒锻,這是一個(gè)標(biāo)準(zhǔn)的UIVIew的動(dòng)畫的實(shí)現(xiàn)。

+ (void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);

這個(gè)方法是用來添加動(dòng)畫序列內(nèi)的不動(dòng)點(diǎn)吱窝。

+ (void)addKeyframeWithRelativeStartTime:(double)frameStartTime relativeDuration:(double)frameDuration animations:(void (^)(void))animations NS_AVAILABLE_IOS(7_0); // start time and duration are values between 0.0 and 1.0 specifying time and duration relative to the overall time of the keyframe animation

@end

@interface UIView (UIViewGestureRecognizers)

@property(nullable, nonatomic,copy) NSArray<__kindof UIGestureRecognizer *> *gestureRecognizers NS_AVAILABLE_IOS(3_2);

- (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer NS_AVAILABLE_IOS(3_2);

- (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer NS_AVAILABLE_IOS(3_2);

// called when the recognizer attempts to transition out of UIGestureRecognizerStatePossible if a touch hit-tested to this view will be cancelled as a result of gesture recognition

// returns YES by default. return NO to cause the gesture recognizer to transition to UIGestureRecognizerStateFailed

// subclasses may override to prevent recognition of particular gestures. for example, UISlider prevents swipes parallel to the slider that start in the thumb

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer NS_AVAILABLE_IOS(6_0);

@end

@interface UIView (UIViewMotionEffects)

/*! Begins applying `effect` to the receiver. The effect's emitted keyPath/value pairs will be

applied to the view's presentation layer.

Animates the transition to the motion effect's values using the present UIView animation

context. */

- (void)addMotionEffect:(UIMotionEffect *)effect NS_AVAILABLE_IOS(7_0);

/*! Stops applying `effect` to the receiver. Any affected presentation values will animate to

their post-removal values using the present UIView animation context. */

- (void)removeMotionEffect:(UIMotionEffect *)effect NS_AVAILABLE_IOS(7_0);

@property (copy, nonatomic) NSArray<__kindof UIMotionEffect *> *motionEffects NS_AVAILABLE_IOS(7_0);

@end

//

// UIView Constraint-based Layout Support

//

typedef NS_ENUM(NSInteger, UILayoutConstraintAxis) {

UILayoutConstraintAxisHorizontal = 0,

UILayoutConstraintAxisVertical = 1

};

// Installing Constraints

/* A constraint is typically installed on the closest common ancestor of the views involved in the constraint.

It is required that a constraint be installed on _a_ common ancestor of every view involved.? The numbers in a constraint are interpreted in the coordinate system of the view it is installed on.? A view is considered to be an ancestor of itself.

*/

@interface UIView (UIConstraintBasedLayoutInstallingConstraints)

返回當(dāng)前view中的所有constrains

@property(nonatomic,readonly) NSArray<__kindof NSLayoutConstraint *> *constraints NS_AVAILABLE_IOS(6_0);

添加單個(gè)constraints

- (void)addConstraint:(NSLayoutConstraint *)constraint NS_AVAILABLE_IOS(6_0); // This method will be deprecated in a future release and should be avoided.? Instead, set NSLayoutConstraint's active property to YES.

添加一組constraint

- (void)addConstraints:(NSArray<__kindof NSLayoutConstraint *> *)constraints NS_AVAILABLE_IOS(6_0); // This method will be deprecated in a future release and should be avoided.? Instead use +[NSLayoutConstraint activateConstraints:].

移除一個(gè)constraint

- (void)removeConstraint:(NSLayoutConstraint *)constraint NS_AVAILABLE_IOS(6_0); // This method will be deprecated in a future release and should be avoided.? Instead set NSLayoutConstraint's active property to NO.

移除一組constraint ? ?

- (void)removeConstraints:(NSArray<__kindof NSLayoutConstraint *> *)constraints NS_AVAILABLE_IOS(6_0); // This method will be deprecated in a future release and should be avoided.? Instead use +[NSLayoutConstraint deactivateConstraints:].

@end

// Core Layout Methods

/* To render a window, the following passes will occur, if necessary.

update constraints

layout

display

Please see the conceptual documentation for a discussion of these methods.

*/

@interface UIView (UIConstraintBasedLayoutCoreMethods)

/*autoLayout的布局過程是update constraints(uodateContraints)->layout subviews(layoutSubviews)->display(drawRect)這三步不是單向的,如果layout的過程中改變了constraint迫靖,就會(huì)觸發(fā)update constraints院峡,進(jìn)行新的一輪迭代。我們?cè)趯?shí)際代碼中系宜,應(yīng)該避免在此造成死循環(huán) */

我們可以調(diào)用這個(gè)方法觸發(fā)update constraints 的操作.在neneedsUpdateContraints返回YES時(shí)照激,才能成功觸發(fā)update Contraints的操作。我們不應(yīng)該重寫這個(gè)方法蜈首。

- (void)updateConstraintsIfNeeded NS_AVAILABLE_IOS(6_0); // Updates the constraints from the bottom up for the view hierarchy rooted at the receiver. UIWindow's implementation creates a layout engine if necessary first.

自定義View時(shí),我們應(yīng)該重寫這個(gè)方法來設(shè)置當(dāng)前View布局的布局約束,重寫這個(gè)方法時(shí)一定要調(diào)用[super updateConstraints]

- (void)updateConstraints NS_AVAILABLE_IOS(6_0); // Override this to adjust your special constraints during a constraints update pass

布局系統(tǒng)使用這個(gè)返回值來確定是否調(diào)用updateConstraints

- (BOOL)needsUpdateConstraints NS_AVAILABLE_IOS(6_0);

當(dāng)一個(gè)自定義的view某一個(gè)屬性的改變可能影響到界面布局实抡,我們應(yīng)該調(diào)用這個(gè)方法來告訴布局系統(tǒng)在未來某個(gè)時(shí)刻需要更新,系統(tǒng)會(huì)調(diào)用updateContraints去更新布局欢策。

- (void)setNeedsUpdateConstraints NS_AVAILABLE_IOS(6_0);

@end

// Compatibility and Adoption

@interface UIView (UIConstraintBasedCompatibility)

/* By default, the autoresizing mask on a view gives rise to constraints that fully determine

the view's position. This allows the auto layout system to track the frames of views whose

layout is controlled manually (through -setFrame:, for example).

When you elect to position the view using auto layout by adding your own constraints,

you must set this property to NO. IB will do this for you.

*/

我們?cè)谑褂么a來寫自己的約束布局代碼時(shí)吆寨,必須設(shè)置當(dāng)前view的translatesAutoresizingMaskIntoContraints為NO,否則無法工作踩寇。

@property(nonatomic) BOOL translatesAutoresizingMaskIntoConstraints NS_AVAILABLE_IOS(6_0); // Default YES

/* constraint-based layout engages lazily when someone tries to use it (e.g., adds a constraint to a view).? If you do all of your constraint set up in -updateConstraints, you might never even receive updateConstraints if no one makes a constraint.? To fix this chicken and egg problem, override this method to return YES if your view needs the window to use constraint-based layout.

*/

返回View是否是約束布局模式

+ (BOOL)requiresConstraintBasedLayout NS_AVAILABLE_IOS(6_0);

@end

// Separation of Concerns

@interface UIView (UIConstraintBasedLayoutLayering)

/* Constraints do not actually relate the frames of the views, rather they relate the "alignment rects" of views.? This is the same as the frame unless overridden by a subclass of UIView.? Alignment rects are the same as the "layout rects" shown in Interface Builder 3.? Typically the alignment rect of a view is what the end user would think of as the bounding rect around a control, omitting ornamentation like shadows and engraving lines.? The edges of the alignment rect are what is interesting to align, not the shadows and such.

*/

/* These two methods should be inverses of each other.? UIKit will call both as part of layout computation.

They may be overridden to provide arbitrary transforms between frame and alignment rect, though the two methods must be inverses of each other.

However, the default implementation uses -alignmentRectInsets, so just override that if it's applicable.? It's easier to get right.

A view that displayed an image with some ornament would typically override these, because the ornamental part of an image would scale up with the size of the frame.

Set the NSUserDefault UIViewShowAlignmentRects to YES to see alignment rects drawn.

*/

返回給定框架的視圖的對(duì)齊矩陣

- (CGRect)alignmentRectForFrame:(CGRect)frame NS_AVAILABLE_IOS(6_0);

返回給定對(duì)齊矩形的視圖的frame

- (CGRect)frameForAlignmentRect:(CGRect)alignmentRect NS_AVAILABLE_IOS(6_0);

/* override this if the alignment rect is obtained from the frame by insetting each edge by a fixed amount.? This is only called by alignmentRectForFrame: and frameForAlignmentRect:.

*/

返回從視圖的frame上定義的對(duì)齊矩陣的邊框

- (UIEdgeInsets)alignmentRectInsets NS_AVAILABLE_IOS(6_0);

返回滿足基線約束條件的視圖

- (UIView *)viewForBaselineLayout NS_DEPRECATED_IOS(6_0, 9_0, "Override -viewForFirstBaselineLayout or -viewForLastBaselineLayout as appropriate, instead") __TVOS_PROHIBITED;

/* -viewForFirstBaselineLayout is called by the constraints system when interpreting

the firstBaseline attribute for a view.

For complex custom UIView subclasses, override this method to return the text-based

(i.e., UILabel or non-scrollable UITextView) descendant of the receiver whose first baseline

is appropriate for alignment.

UIView's implementation returns [self viewForLastBaselineLayout], so if the same

descendant is appropriate for both first- and last-baseline layout you may override

just -viewForLastBaselineLayout.

*/


@property(readonly,strong) UIView *viewForFirstBaselineLayout NS_AVAILABLE_IOS(9_0);

/* -viewForLastBaselineLayout is called by the constraints system when interpreting

the lastBaseline attribute for a view.

For complex custom UIView subclasses, override this method to return the text-based

(i.e., UILabel or non-scrollable UITextView) descendant of the receiver whose last baseline

is appropriate for alignment.

UIView's implementation returns self.

*/

@property(readonly,strong) UIView *viewForLastBaselineLayout NS_AVAILABLE_IOS(9_0);

/* Override this method to tell the layout system that there is something it doesn't natively understand in this view, and this is how large it intrinsically is.? A typical example would be a single line text field.? The layout system does not understand text - it must just be told that there's something in the view, and that that something will take a certain amount of space if not clipped.

In response, UIKit will set up constraints that specify (1) that the opaque content should not be compressed or clipped, (2) that the view prefers to hug tightly to its content.

A user of a view may need to specify the priority of these constraints.? For example, by default, a push button

-strongly wants to hug its content in the vertical direction (buttons really ought to be their natural height)

-weakly hugs its content horizontally (extra side padding between the title and the edge of the bezel is acceptable)

-strongly resists compressing or clipping content in both directions.

However, you might have a case where you'd prefer to show all the available buttons with truncated text rather than losing some of the buttons. The truncation might only happen in portrait orientation but not in landscape, for example. In that case you'd want to setContentCompressionResistancePriority:forAxis: to (say) UILayoutPriorityDefaultLow for the horizontal axis.

The default 'strong' and 'weak' priorities referred to above are UILayoutPriorityDefaultHigh and UILayoutPriorityDefaultLow.

Note that not all views have an intrinsicContentSize.? UIView's default implementation is to return (UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric).? The _intrinsic_ content size is concerned only with data that is in the view itself, not in other views. Remember that you can also set constant width or height constraints on any view, and you don't need to override instrinsicContentSize if these dimensions won't be changing with changing view content.

*/

UIKIT_EXTERN const CGFloat UIViewNoIntrinsicMetric NS_AVAILABLE_IOS(6_0); // -1

返回接收對(duì)象的原本大小

- (CGSize)intrinsicContentSize NS_AVAILABLE_IOS(6_0);

廢除視圖原本內(nèi)容的size

- (void)invalidateIntrinsicContentSize NS_AVAILABLE_IOS(6_0); // call this when something changes that affects the intrinsicContentSize.? Otherwise UIKit won't notice that it changed.

設(shè)置當(dāng)視圖要變大時(shí)啄清,視圖的放大改變方式,是水平放大還是垂直放大,并返回一個(gè)優(yōu)先權(quán)

- (UILayoutPriority)contentHuggingPriorityForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);

設(shè)置優(yōu)先權(quán)

- (void)setContentHuggingPriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);

設(shè)置當(dāng)視圖要變小時(shí)辣卒,視圖的壓縮改變方式掷贾,是水平縮小還是垂直縮小,并返回一個(gè)優(yōu)先權(quán)

- (UILayoutPriority)contentCompressionResistancePriorityForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);

設(shè)置優(yōu)先權(quán)

- (void)setContentCompressionResistancePriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);

@end

// Size To Fit

UIKIT_EXTERN const CGSize UILayoutFittingCompressedSize NS_AVAILABLE_IOS(6_0);

UIKIT_EXTERN const CGSize UILayoutFittingExpandedSize NS_AVAILABLE_IOS(6_0);

@interface UIView (UIConstraintBasedLayoutFittingSize)

/* The size fitting most closely to targetSize in which the receiver's subtree can be laid out while optimally satisfying the constraints. If you want the smallest possible size, pass UILayoutFittingCompressedSize; for the largest possible size, pass UILayoutFittingExpandedSize.

Also see the comment for UILayoutPriorityFittingSizeLevel.

*/

返回最合適的尺寸

- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSize NS_AVAILABLE_IOS(6_0); // Equivalent to sending -systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority: with UILayoutPriorityFittingSizeLevel for both priorities.


- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSize withHorizontalFittingPriority:(UILayoutPriority)horizontalFittingPriority verticalFittingPriority:(UILayoutPriority)verticalFittingPriority NS_AVAILABLE_IOS(8_0);

@end

@interface UIView (UILayoutGuideSupport)

/* UILayoutGuide objects owned by the receiver.

*/

限制View的位置

@property(nonatomic,readonly,copy) NSArray<__kindof UILayoutGuide *> *layoutGuides NS_AVAILABLE_IOS(9_0);

/* Adds layoutGuide to the receiver, passing the receiver in -setOwningView: to layoutGuide.

*/

- (void)addLayoutGuide:(UILayoutGuide *)layoutGuide NS_AVAILABLE_IOS(9_0);

/* Removes layoutGuide from the receiver, passing nil in -setOwningView: to layoutGuide.

*/

- (void)removeLayoutGuide:(UILayoutGuide *)layoutGuide NS_AVAILABLE_IOS(9_0);

@end

@class NSLayoutXAxisAnchor,NSLayoutYAxisAnchor,NSLayoutDimension;

@interface UIView (UIViewLayoutConstraintCreation)

/* Constraint creation conveniences. See NSLayoutAnchor.h for details.

*/

@property(readonly, strong) NSLayoutXAxisAnchor *leadingAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutXAxisAnchor *trailingAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutXAxisAnchor *leftAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutXAxisAnchor *rightAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutYAxisAnchor *topAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutYAxisAnchor *bottomAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutDimension *widthAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutDimension *heightAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutXAxisAnchor *centerXAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutYAxisAnchor *centerYAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutYAxisAnchor *firstBaselineAnchor NS_AVAILABLE_IOS(9_0);

@property(readonly, strong) NSLayoutYAxisAnchor *lastBaselineAnchor NS_AVAILABLE_IOS(9_0);

@end

// Debugging

/* Everything in this section should be used in debugging only, never in shipping code.? These methods may not exist in the future - no promises.

*/

@interface UIView (UIConstraintBasedLayoutDebugging)

/* This returns a list of all the constraints that are affecting the current location of the receiver.? The constraints do not necessarily involve the receiver, they may affect the frame indirectly.

Pass UILayoutConstraintAxisHorizontal for the constraints affecting [self center].x and CGRectGetWidth([self bounds]), and UILayoutConstraintAxisVertical for the constraints affecting[self center].y and CGRectGetHeight([self bounds]).

*/

約束檢查為什么這個(gè)View這樣顯示返回值,約束條件

- (NSArray<__kindof NSLayoutConstraint *> *)constraintsAffectingLayoutForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);

/* If there aren't enough constraints in the system to uniquely determine layout, we say the layout is ambiguous.? For example, if the only constraint in the system was x = y + 100, then there are lots of different possible values for x and y.? This situation is not automatically detected by UIKit, due to performance considerations and details of the algorithm used for layout.

The symptom of ambiguity is that views sometimes jump from place to place, or possibly are just in the wrong place.

-hasAmbiguousLayout runs a check for whether there is another center and bounds the receiver could have that could also satisfy the constraints.

-exerciseAmbiguousLayout does more.? It randomly changes the view layout to a different valid layout.? Making the UI jump back and forth can be helpful for figuring out where you're missing a constraint.

*/

判斷當(dāng)前的自動(dòng)布局約束是否還有其他滿足約束的條件

- (BOOL)hasAmbiguousLayout NS_AVAILABLE_IOS(6_0);

隨機(jī)實(shí)現(xiàn)一個(gè)滿足約束的條件

- (void)exerciseAmbiguityInLayout NS_AVAILABLE_IOS(6_0);

@end

@interface UIView (UIStateRestoration)

@property (nullable, nonatomic, copy) NSString *restorationIdentifier NS_AVAILABLE_IOS(6_0);

歸檔時(shí)編碼

- (void) encodeRestorableStateWithCoder:(NSCoder *)coder NS_AVAILABLE_IOS(6_0);

反歸檔時(shí)解碼

- (void) decodeRestorableStateWithCoder:(NSCoder *)coder NS_AVAILABLE_IOS(6_0);

@end

@interface UIView (UISnapshotting)

/*

* When requesting a snapshot, 'afterUpdates' defines whether the snapshot is representative of what's currently on screen or if you wish to include any recent changes before taking the snapshot.

If called during layout from a committing transaction, snapshots occurring after the screen updates will include all changes made, regardless of when the snapshot is taken and the changes are made. For example:

- (void)layoutSubviews {

UIView *snapshot = [self snapshotViewAfterScreenUpdates:YES];

self.alpha = 0.0;

}

The snapshot will appear to be empty since the change in alpha will be captured by the snapshot. If you need to animate the view during layout, animate the snapshot instead.

* Creating snapshots from existing snapshots (as a method to duplicate, crop or create a resizable variant) is supported. In cases where many snapshots are needed, creating a snapshot from a common superview and making subsequent snapshots from it can be more performant. Please keep in mind that if 'afterUpdates' is YES, the original snapshot is committed and any changes made to it, not the view originally snapshotted, will be included.

*/

復(fù)制一個(gè)復(fù)合視圖

afterUpdates? ? 是否視圖展示時(shí)才生成視圖

No ? ?會(huì)立即生成快照荣茫,并不會(huì)調(diào)用重新設(shè)置顏色的方法無色

YES ? ?當(dāng)調(diào)用這個(gè)視圖時(shí)生成

- (UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates NS_AVAILABLE_IOS(7_0);

復(fù)制一個(gè)指定范圍偏移量的復(fù)合視圖

- (UIView *)resizableSnapshotViewFromRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates withCapInsets:(UIEdgeInsets)capInsets NS_AVAILABLE_IOS(7_0);? // Resizable snapshots will default to stretching the center

// Use this method to render a snapshot of the view hierarchy into the current context. Returns NO if the snapshot is missing image data, YES if the snapshot is complete. Calling this method from layoutSubviews while the current transaction is committing will capture what is currently displayed regardless if afterUpdates is YES.

該方法對(duì)指定UIView作用想帅,通過將UIView的內(nèi)容繪制到圖形上下文上然后獲取圖像來達(dá)到截取UIView的效果。

- (BOOL)drawViewHierarchyInRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates NS_AVAILABLE_IOS(7_0);

@end

NS_ASSUME_NONNULL_END

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末啡莉,一起剝皮案震驚了整個(gè)濱河市港准,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌咧欣,老刑警劉巖浅缸,帶你破解...
    沈念sama閱讀 217,277評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異魄咕,居然都是意外死亡衩椒,警方通過查閱死者的電腦和手機(jī)弄抬,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,689評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門启昧,熙熙樓的掌柜王于貴愁眉苦臉地迎上來脓恕,“玉大人友驮,你說我怎么就攤上這事速警√僭希” “怎么了沉馆?”我有些...
    開封第一講書人閱讀 163,624評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵汰扭,是天一觀的道長囤躁。 經(jīng)常有香客問我冀痕,道長,這世上最難降的妖魔是什么狸演? 我笑而不...
    開封第一講書人閱讀 58,356評(píng)論 1 293
  • 正文 為了忘掉前任言蛇,我火速辦了婚禮,結(jié)果婚禮上宵距,老公的妹妹穿的比我還像新娘腊尚。我一直安慰自己,他們只是感情好满哪,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,402評(píng)論 6 392
  • 文/花漫 我一把揭開白布婿斥。 她就那樣靜靜地躺著,像睡著了一般哨鸭。 火紅的嫁衣襯著肌膚如雪民宿。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,292評(píng)論 1 301
  • 那天像鸡,我揣著相機(jī)與錄音活鹰,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛志群,可吹牛的內(nèi)容都是我干的着绷。 我是一名探鬼主播,決...
    沈念sama閱讀 40,135評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼锌云,長吁一口氣:“原來是場噩夢啊……” “哼荠医!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起桑涎,我...
    開封第一講書人閱讀 38,992評(píng)論 0 275
  • 序言:老撾萬榮一對(duì)情侶失蹤子漩,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后石洗,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,429評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡紧显,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,636評(píng)論 3 334
  • 正文 我和宋清朗相戀三年讲衫,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片孵班。...
    茶點(diǎn)故事閱讀 39,785評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡涉兽,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出篙程,到底是詐尸還是另有隱情枷畏,我是刑警寧澤,帶...
    沈念sama閱讀 35,492評(píng)論 5 345
  • 正文 年R本政府宣布虱饿,位于F島的核電站拥诡,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏氮发。R本人自食惡果不足惜渴肉,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,092評(píng)論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望爽冕。 院中可真熱鬧仇祭,春花似錦、人聲如沸颈畸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,723評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽眯娱。三九已至礁苗,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間困乒,已是汗流浹背寂屏。 一陣腳步聲響...
    開封第一講書人閱讀 32,858評(píng)論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人迁霎。 一個(gè)月前我還...
    沈念sama閱讀 47,891評(píng)論 2 370
  • 正文 我出身青樓吱抚,卻偏偏與公主長得像,于是被迫代替她去往敵國和親考廉。 傳聞我的和親對(duì)象是個(gè)殘疾皇子秘豹,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,713評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容