简体   繁体   中英

Hide and show view in swift 4.2 xcode

I am new to iOS app development. i have created the view like below. 在此处输入图像描述

and i am reusing the same view in other screen. so that screen dont need the "ss" Initials. so i have hidden than programmatically.like below. 在此处输入图像描述

here i am facing the unwanted spacing issue on second screen.

What i want is, when the "SS" initials hidden, the name and subject need to come to the left aligned. i don't know what content need to give for google it. guys please give some keyword to find solution or please give some solution to it.

You can use UIStackView for this problem.

let us call everything but the UIImageView is the RHS and the UIImageView is the LHS

place them in a vertical UIStackView and when you hide the UIImageView it should automatically remove that spacing and shift the content to fill the view.

If you haven't seen them yet I recommend this tutorial.

If you do not want to use stackViews you can physically move the label by "animating" it or moving its frame.

self.labelToMove.frame = CGRect(x: x, y: y, width: width, height: height)

Call this line with the desired position wherever you programatically "hide" the image view.

you can move it back by doing the same thing when you programmatically "unhide" the initials image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM