iOS aotoresizing的基本使用
来源:互联网 发布:什么是绿色版软件 编辑:程序博客网 时间:2024/04/24 10:07
//
// ViewController.m
// 自动布局01
//
// Created by 唐帅 on 16/4/16.
// Copyright © 2016年 tang. All rights reserved.
//
#import "ViewController.h"
@interfaceViewController ()
@property(nonatomic,weak)UIView *blueView;
@property(nonatomic,weak)UIView *redView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
UIView *blueView = [[UIViewalloc]init];
blueView.backgroundColor = [UIColorblueColor];
blueView.frame =CGRectMake(100,100, 100,100);
self.blueView = blueView;
[self.viewaddSubview:blueView];
UIView *redView = [[UIViewalloc]init];
redView.backgroundColor = [UIColorredColor];
redView.frame =CGRectMake(25,25, 50,50);
self.redView = redView;
[blueView addSubview:redView];
// 给红色view添加约束
// UIViewAutoresizingNone = 0,
// UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
// UIViewAutoresizingFlexibleRightMargin = 1 << 2,
// UIViewAutoresizingFlexibleTopMargin = 1 << 3,
// UIViewAutoresizingFlexibleBottomMargin = 1 << 5
//让红色的view向右下跟随蓝色view移动
self.redView.autoresizingMask =UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleTopMargin;
}
//触摸屏幕发生的事件
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
CGRect bounds =self.blueView.bounds;
bounds.size.width +=50;
bounds.size.height +=50;
self.blueView.bounds = bounds;
NSLog(@"%@",NSStringFromCGRect(self.blueView.bounds));
}
@end
- iOS aotoresizing的基本使用
- IOS sqlit3的基本使用
- ios 动画的基本使用
- ios MBProgressHUD的基本使用
- iOS GCD的基本使用
- iOS MapKit的基本使用
- iOS 大头针的基本使用
- iOS CoreData的基本使用
- iOS UITableView的基本使用
- iOS cocoPod的基本使用
- ios蓝牙的基本使用
- iOS多线程的基本使用
- IOS Xib的基本使用
- IOS ibeacon的基本使用
- ios Sqlite 的基本使用
- iOS TableView的基本使用
- iOS Coredata的基本使用
- ios websocket的基本使用
- Android学习(25) -- 单元测试(JUnit Test)
- AltiumDesigner学习笔记
- LeetCode 202. Happy Number
- iOS autolayout 的基本使用(用代码添加约束)
- AD(Alitium Designer)中ROOM的使用
- iOS aotoresizing的基本使用
- 那些相见恨晚的android studio快捷键
- 爬虫的道魔策略
- LeetCode 83. Remove Duplicates from Sorted List
- Python正则表达式指南
- C++学习笔记
- 五个常用MySQL图形化管理工具
- LeetCode 266. Palindrome Permutation
- 敏捷开发的一次实践-划分模块