UIView的常見屬性,UIView常見屬性

來源:互聯網
上載者:User

UIView的常見屬性,UIView常見屬性


UIView的常見屬性:@interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem>/** *  通過一個frame來初始化一個UI控制項 */- (id)initWithFrame:(CGRect)frame;// YES:能夠跟使用者進行互動@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled;  // default is YES// 控制項的一個標記(父控制項可以通過tag找到對應的子控制項)@property(nonatomic)                                 NSInteger tag;                // default is 0// 圖層(可以用來設定圓角效果\陰影製作效果)@property(nonatomic,readonly,retain)                 CALayer  *layer;@end@interface UIView(UIViewGeometry)// 位置和尺寸(以父控制項的左上方為座標原點(0, 0))@property(nonatomic) CGRect            frame;// 位置和尺寸(以自己的左上方為座標原點(0, 0))@property(nonatomic) CGRect            bounds;// 中點(以父控制項的左上方為座標原點(0, 0))@property(nonatomic) CGPoint           center;// 形變屬性(平移\縮放\旋轉)@property(nonatomic) CGAffineTransform transform;   // default is CGAffineTransformIdentity// YES:支援多點觸摸@property(nonatomic,getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled;   // default is NO@end@interface UIView(UIViewHierarchy)// 父控制項@property(nonatomic,readonly) UIView       *superview;// 子控制項(新添加的控制項預設都在subviews數組的後面, 新添加的控制項預設都顯示在最上面\最頂部)@property(nonatomic,readonly,copy) NSArray *subviews;// 獲得當前控制項所在的window@property(nonatomic,readonly) UIWindow     *window;// 從父控制項中移除一個控制項- (void)removeFromSuperview;// 添加一個子控制項(可以將子控制項插入到subviews數組中index這個位置)- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;// 交換subviews數組中所存放子控制項的位置- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;// 添加一個子控制項(新添加的控制項預設都在subviews數組的後面, 新添加的控制項預設都顯示在最上面\最頂部)- (void)addSubview:(UIView *)view;// 添加一個子控制項view(被擋在siblingSubview的下面)- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;// 添加一個子控制項view(蓋在siblingSubview的上面)- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;// 將某個子控制項拉到最上面(最頂部)來顯示- (void)bringSubviewToFront:(UIView *)view;// 將某個子控制項拉到最下面(最底部)來顯示- (void)sendSubviewToBack:(UIView *)view;/**系統自動調用(留給子類去實現), 這些方法就可以叫做"事件方法", 由系統調用。**/- (void)didAddSubview:(UIView *)subview;- (void)willRemoveSubview:(UIView *)subview;- (void)willMoveToSuperview:(UIView *)newSuperview;- (void)didMoveToSuperview;- (void)willMoveToWindow:(UIWindow *)newWindow;- (void)didMoveToWindow;/**系統自動調用**/// 是不是view的子控制項或者子控制項的子控制項(是否為view的後代)- (BOOL)isDescendantOfView:(UIView *)view;  // returns YES for self.// 通過tag獲得對應的子控制項(也可以或者子控制項的子控制項)- (UIView *)viewWithTag:(NSInteger)tag;     // recursive search. includes self/**系統自動調用(留給子類去實現)**/// 控制項的frame發生改變的時候就會調用,一般在這裡重寫布局子控制項的位置和尺寸// 重寫了這個寫方法後,一定調用[super layoutSubviews];- (void)layoutSubviews;@end@interface UIView(UIViewRendering)// YES : 超出控制項邊框範圍的內容都剪掉@property(nonatomic)                 BOOL              clipsToBounds;// 背景色@property(nonatomic,copy)            UIColor          *backgroundColor; // default is nil// 透明度(0.0~1.0)@property(nonatomic)                 CGFloat           alpha;                      // default is 1.0// YES:不透明  NO:透明@property(nonatomic,getter=isOpaque) BOOL              opaque;                     // default is YES// YES : 隱藏  NO : 顯示@property(nonatomic,getter=isHidden) BOOL              hidden;// 內容模式@property(nonatomic)                 UIViewContentMode contentMode;                // default is UIViewContentModeScaleToFill@end@interface UIView(UIViewAnimationWithBlocks)+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;@end

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.