0

I need to update UIView size.

Now i use

var titleSize = CGRectMake(0, 30, 40 , 1000)

self.contentCoverScrollView.frame = titleSize

in viewDidLoad, but nothing happens.

2
  • 3
    Are you using AutoLayout in your project? Commented May 27, 2015 at 9:18
  • Yes but This view not have any Constrain. Commented May 27, 2015 at 9:21

3 Answers 3

4

In Autolayout if you want to change the frame then try the constraints (IBOutlet of NSLayoutConstraint).

enter image description here

Set the constraint outlets and change constant value by :

self.sampleConstraint.constant = 20
self.view.layoutIfNeeded()
Sign up to request clarification or add additional context in comments.

Comments

0

I thought you had used the AutoLayout in your application that's why it can not change the view frame, please write the below code.

var titleSize = CGRectMake(0, 30, 40 , 1000)

self.contentCoverScrollView.frame = titleSize

[self.contentCoverScrollView updateConstraintsIfNeeded];

Note : updateConstraintsIfNeeded will tell the system to recalculate the constraints in that particular moment of execution.

Comments

0

Look like you want to change ScrollView size use:

[self.contentCoverScrollView setContentSize:(CGSizeMake(40, 1000))];

2 Comments

In Swift: self.contentCoverScrollView.contentSize = CGSize(width:40, height: 1000)
This is not a ScrollView just Uiview sorry for confusing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.