Noorul
Noorul

Reputation: 3444

Hide and show view in swift 4.2 xcode

I am new to iOS app development. i have created the view like below.enter image description here

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. enter image description here

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.

Upvotes: 1

Views: 154

Answers (2)

Julian Silvestri
Julian Silvestri

Reputation: 2037

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

Upvotes: 2

Mohmmad S
Mohmmad S

Reputation: 5098

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.

Upvotes: 3

Related Questions