'iOS: how to change the direction of the view resize animation

I'm working on a screen in which I have a UIScrollView in it I need to provide a functionality of resizing for a UIView and UILabel. All the views are added to the UIScrollView with layout constraints.

Now to change the size of the UILabel I use the following code:

desriptionLabel.numberOfLines = desriptionLabel.numberOfLines == 0 ? 1 : 0
UIView.animate(withDuration: 0.5) {
    self.descriptionView.layoutIfNeeded()
}

To change the view size I have created an IBOutlet for the height constraint of this view and I do the following:

if additionalSocialViewHeightConstraint.constant == 60 {
    additionalSocialViewHeightConstraint.constant = 240
} else {
    additionalSocialViewHeightConstraint.constant = 60
}
    
UIView.animate(withDuration: 0.5) {
   self.additonalSocialView.layoutIfNeeded()
}

Now both animations do work and resize the label and view accordingly, the problem I'm having is with the way those animations work.

in both cases, the animations expends the view from a center and out. So for the label, the view of the label grows immediately to the expected size to fit all the label text, and then the text starts to spread from one line in the center of the big view in both directions up and down.

In the case of the view. again the view first enlarges the space around it where the initial view is placed in the middle of this space and then it grows in both up and down directions to take up all the space.

The Problem: Now because I'm in a UIScrollView this does not look good and I need to change the animation from starting in the middle and spreading in both direction to start at the top and spread only to the bottom. Also, I need the shrinking to the original size animation to work in the same manner, meaning shrinking the view from bottom to top.

The Question: How should I manage this kind of animation? What am I doing wrong?

Constraints configuration for both view:

UILabel:

enter image description here

UIView:

enter image description here



Solution 1:[1]

• You can surely go ahead with your approach 1 as it is the most correct way of granting the required permissions to a daemon application via Microsoft Graph API to the Sharepoint resources. But in that approach, you can surely restrict access to that daemon app to a certain group for sure as below: -

a) Register the Sharepoint online application in your Azure AD in Enterprise Applications. Once done, open the application which wants access to sharepoint resources in ‘App registrations’ in your Azure AD and grant ‘Microsoft Graph API’ and Sharepoint online the required permissions through ‘API permissions’ section as below: - Registering the app

b) Once the permissions such as ‘Files.Readwrite.All’ and other permissions to access your daemon application are consented for, open your daemon application in ‘Enterprise Applications’ by clicking on the ‘Go to Enterprise Applications’ link as below: - Enterprise applications

c) Then, click on ‘Users and groups’ option under ‘Manage’ section and add the group that you want to give access to this application as below. Once the group required has been added in here, the members in this group only will be able to access the resources in Sharepoint online. Adding groups

Thus, in this way, you can assign a group access to the sharepoint resources through a daemon application via Microsoft graph.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KartikBhiwapurkar-MT