UIView animated changes with auto layout constraints

前端 未结 3 1638
青春惊慌失措
青春惊慌失措 2020-12-23 14:29

Say that I have a project which looks like the following:

\"enter

There are tw

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 15:02

    //
    //  WPViewController.h
    //  AutoLayoutTEst
    //
    //  Created by VASANTH K on 09/01/14.
    //  
    //
    
    #import 
    
    @interface WPViewController : UIViewController
    @property (strong, nonatomic) IBOutlet UIButton *button1;
    - (IBAction)buttClicked:(id)sender;
    @property (strong, nonatomic) IBOutlet NSLayoutConstraint *heightConstrain;
    
    @property (strong, nonatomic) IBOutlet UIButton *button2;
    @end
    

    click Event

    - (IBAction)buttClicked:(id)sender {
    
    
        self.heightConstrain.constant=100;
    
    
    }
    

    here u need to set the heightConstrain for the Yellow button then create reference outlet for that button then update the heightConstrain to update the size of that button it will automatically move your Red button down.

    https://github.com/vasanth3008/AutoLayoutHeighDemo

    refer my sample demo project

提交回复
热议问题