//
// ViewController.m
// iosstudy2024
//
// Created by figo on 2024/8/5.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *xigua;
- (IBAction)xigua:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (IBAction)xigua:(id)sender {
NSLog(@"这里是西瓜!");
//1.通过frame设置位置(+是向右和向下)和大小
/** */
CGRect originFrame=_xigua.frame;
originFrame.size.width+=10;
originFrame.size.height+=10;
originFrame.origin.x+=10;
originFrame.origin.y+=10;
_xigua.frame=originFrame;
//2.通过center设置位置,center是中心点
/**
CGPoint centerPoint=_xigua.center;
centerPoint.x+=10;
centerPoint.y+=10;
_xigua.center=centerPoint;
*/
//3.通过bounds设置位置(+是向左和向上)和大小
/**
CGRect originBounds=_xigua.bounds;
originBounds.size.width+=10;
originBounds.size.height+=10;
originBounds.origin.x+=10;
originBounds.origin.y+=10;
_xigua.bounds=originBounds;
*/
}
@end
ios修改控件大小及位置的方法
于 2024-08-06 09:23:33 首次发布