Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of UIView View

Shulou Source: shulou.com Published: 2022-06-02 03:46:22 09月30日 Update

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.

Tags: Views arrays examples analysis content skills knowledge types order concise consistent concise central point location variables places characters strings that is attributes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL macOS MariaDB Xiaomi