Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of UIView View

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you the sample analysis of UIView view, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Create a view

UIView * view = [UIView alloc] initWithFrame:CGRectMake (220,100,100,100)]

View.backgroundColor = [UIColor greenColor]

[self.window addSubview:view]

[view release]

The view1.center center property gets the center point of the view.

NSStringFromCGPoint converts a CGPoint type structure variable to a string type.

NSLog (@ "% @", NSStringFromCGPoint (view1.center))

Frame of the view

NSLog (@ "% @", NSStringFromCGRect (view1.frame))

Transparency alpha

View1.alpha = 0.5

Explicit and implicit hidden 1 hide 0 does not hide default: do not hide

View1.hidden = 0

[self.window addSubview:view1]; / / add directly to the front

View1.frame = CGRectMake (120,234,100,100)

[self.window addSubview:view1]

View1.frame = CGRectMake (120,333,100,100)

[self.window addSubview:view1]

[self.window insertSubview:view1 atIndex:0]; / / add to the 0 position of the array

[self.window insertSubview:view1 aboveSubview:view]; / / insert the View1 subview into the view

[self.window insertSubview:view1 belowSubview:view]; / / insert the View1 subview under the view

View1.tag = 100; / / tag is used to uniquely identify a view (given above 100)

Get all the child view subviews of the view

Views manage all child views in the form of an array, and the order in the array is the same as the order in which the views are submitted.

If the added view coincides with the previously added view, the first added view will be overwritten.

NSLog (@ "% @", self.window.subviews)

Get the parent view superview of the view

NSLog (@ "% @", view1.superview)

[view1 release]

[self.window viewWithTag:100]

Obtain the corresponding child view through the teg value of the parent view and the child view

The above is a sample analysis of the UIView view. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report