UIView 是視圖基類,以下這這類結構圖可以看出view 常用UI空間都是這個類的子類
1 view 位置幾何 UIViewGeometry
常用的有
frame
bounds
center
transform(默認是CGAffineTransformIdentity。可以做成動畫)
multipleTouchEnabled(當前視圖是否接受多點觸控事件,缺省值爲NO)
exclusiveTouch (當前視圖是否接受單點觸控,默認值是no)
autoresizesSubviews(這個屬性是決定當視圖大小邊界發生改變時,其子視圖是否也跟着自動調整大小)
autoresizingMask(簡單的調整。默認是UIViewAutoresizingNone)
2: UIView層次結構
superview(父視圖)
subviews(子視圖)返回時數組
window(窗口)
- (void)removeFromSuperview;(從父視圖上移除)
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;(插入一個視圖在index處)
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;(切換兩個視圖位置)
- (void)addSubview:(UIView *)view;(添加視圖)
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;(添加到哪個視圖之上)
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;(添加到哪個個視圖之下)
- (void)bringSubviewToFront:(UIView *)view;(將子視圖至前)
- (void)sendSubviewToBack:(UIView *)view;(將子視圖放到後面)
- (void)didAddSubview:(UIView *)subview;()
- (void)willRemoveSubview:(UIView *)subview;(將要移除子視圖)
- (nullable __kindof UIView *)viewWithTag:(NSInteger)tag;(根據tag值獲取視圖)
- (void)setNeedsLayout;(強制佈局)
- (void)layoutIfNeeded;
3: UIViewRendering(UIView呈現)
clipsToBounds(是的,內容和子視圖省略視圖的範圍。默認是否定的。)
alpha (透明度,默認值是一)
hidden(是否隱藏視圖,默認是不隱藏)
tintColor (色調顏色,開始用於IOS7)
4:UIViewAnimation(視圖動畫)
+ (void)beginAnimations:(nullable NSString *)animationID context:(nullable void *)context;(UIViewRenderingadditional上下文信息傳遞給會啓動/停止選擇器。開始/提交可以嵌套)
+ (void)commitAnimations;開始動畫
+ (void)setAnimationDelegate:(nullable id)delegate;(設置代理)
+ (void)setAnimationWillStartSelector:(nullable SEL)selector; // default = NULL. -animationWillStart:(NSString *)animationID context:(void *)context
+ (void)setAnimationDidStopSelector:(nullable SEL)selector; // default = NULL. -animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
+ (void)setAnimationDuration:(NSTimeInterval)duration; // default = 0.2
+ (void)setAnimationDelay:(NSTimeInterval)delay; // default = 0.0
+ (void)setAnimationStartDate:(NSDate *)startDate;
5:UIViewAnimationWithBlocks(動畫塊)
常用的方法
1 + (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);
2 + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0
*/