最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【整理】iOS中的UIView的基础知识

iOS crifan 3039浏览 0评论

 

坐标Geometry,坐标系Coordinate system

其实这部分只是,也是属于:
Cocoa中的坐标系Coordinate system的知识
参考:
有:
coordinate system in ios and mac

即:

iOS中的坐标系:左上角是坐标原点(0, 0),然后水平向右是x值增加,垂直向下是y值增加

Mac中的坐标系:左下角是坐标原点(0, 0),然后水平向右是x值增加,垂直向上是y值增加

x y position

 

[frame,bounds,center]

frame bounds center for postion viewYou Probably Don’t Understand frames and bounds – Ash Furrow

 View视图中的常见值的含义

Among the properties you can animate on a UIView object are the following:

  • frame—Use this to animate position and size changes for the view.
  • bounds—Use this to animate changes to the size of the view.
  • center—Use this to animate the position of the view.
  • transform—Use this to rotate or scale the view.
  • alpha—Use this to change the transparency of the view.
  • backgroundColor—Use this to change the background color of the view.
  • contentStretch—Use this to change how the view’s contents stretch.

 

frame

该view在父view坐标系统中的位置和大小。(参照点是,父亲的坐标系统)

bounds

该view在本地坐标系统中的位置和大小。(参照点是,本地坐标系统,就相当于ViewB自己的坐标系统,以0,0点为起点)

center

该view的中心点在父view坐标系统中的位置和大小。(参照点是,父亲的坐标系统)

 

画矩形的视图

有三种方式:

  • UIKit
  • Core Graphics
  • OpenGL ES

 

参考资料

深入探究frame和bounds的区别以及setbounds使用 – CocoaChina_让移动开发更简单

ios view的frame和bounds之区别(位置和大小) – 其实并不难,是你太悲观 – 博客频道 – CSDN.NET

swift UIView frame size

View Controller Programming Guide for iOS: Defining Your Subclass

frame – UIView Class Reference

About Drawing and Printing in iOS

View Controller Programming Guide for iOS: The Role of View Controllers

View and Window Architecture

 

转载请注明:在路上 » 【整理】iOS中的UIView的基础知识

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
85 queries in 0.165 seconds, using 22.14MB memory