`
zhangyaochun
  • 浏览: 2614500 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

initWithFrame

 
阅读更多

 

   initWithFrame 用来初始化并返回一个新的视图对象,根据指定的 CGRect (尺寸)

 

   用编程方式申明,创建 UIView 对象时候,使用 initWithFrame 方法。

 

 

 

 

 

  地址:https://www.cnblogs.com/lv14/articles/5013262.html

 

  https://www.jianshu.com/p/19c083751497

 

  https://segmentfault.com/q/1010000011473155

 

  https://www.cnblogs.com/yajunLi/p/6344023.html

分享到:
评论

相关推荐

    initWithCoder与initWithFrame

    每个ios开发者对loadView和viewDidLoad肯定都很熟悉,虽然这两个函数使用上真的是非常简单,但是和类似的initWithNibName/awakeFromNib/initWithCoder放在一起还是非常容易让人混淆的. 昨天看了下苹果官方的相关文档...

    ios开发记录

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; Screen 屏 //让window显示到屏幕上 [self.window makeKeyAndVisible]; Visible可见的 //得到全局的屏幕对象 UIScreen *...

    ios开发小技巧

    UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 109.0f)]; [myImage setImage:[UIImage imageNamed:@"myImage.png"]]; myImage.opaque = YES; [self.view addSubview:...

    联网指示器效果

    - (id)initWithFrame:(CGRect)frame andStyle:(WMProgressStyle)styleType andTitle:(NSString *)title ZZProgressHUD. { if (self = [super initWithFrame:frame]) { _frame = frame; self.styleType = style...

    iOS经验之初始化方法中不该设置self.view的属性浅析

    iOS初始化方法包括系统默认的和自定义的,常见系统初始化方法有init, initWithFrame:, initWithNibName:bundle:等,自定义则是各式各样。日常iOS项目开发过程中,我们经常在类的初始化方法中初始化接下来类需要用到...

    ios-水波图;支文字在2种颜色之间交换显示;.zip

    self.percentView = [[ZBPercentWaterView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)]; [self.view addSubview:self.percentView]; //设置进度: [self.percentView setupProgress:(arc4random...

    封装版_小白点_类似于 AssistiveTouch 的漂浮按钮

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; view.backgroundColor = [UIColor redColor]; UIView *blue = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; blue....

    cocoa animation examples

    mover = [[NSImageView alloc] initWithFrame:moverFrame]; [mover setImageScaling:NSScaleToFit]; [mover setImage:[NSImage imageNamed:@"photo.jpg"]]; [self addSubview:mover]; } - (id)initWithFrame:...

    封装好的类似于 AssistiveTouch 的漂浮按钮

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; view.backgroundColor = [UIColor redColor]; UIView *blue = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; blue....

    iOS自定义collectionView实现毛玻璃效果

    说下思路,很简单,首先自定义一个collectionView, 重写它的initWithFrame:collectionViewLayout:方法,在这里面做配置,这里用的是AXECollectionView. 与之对应的自定义一个collectionViewCell,在cell里配置操作:设置...

    长按拖动排序

    // StBtnTouchMove *stBtn = [[StBtnTouchMove alloc]initWithFrame:CGRectMake(0, 200, 375, 100)]; // [self.view addSubview:stBtn]; // stBtn.buttonArray = [[NSMutableArray alloc]init]; // for (NSInteger i...

    ios中文开发教程资料全收录

    在iOS开发中,`loadView` 和 `initWithFrame:` 是两个重要的初始化方法,它们分别负责视图的加载和初始化工作。 - **initWithFrame:** 该方法是UIView及其子类的默认初始化方法,用于设置视图的初始框架大小。 - ...

    UI课件第一讲

    UIView *blueView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 120, 100)]; blueView.backgroundColor = [UIColor blueColor]; [self.window addSubview:blueView]; [blueView release]; ``` #### ...

    iOS简单实现遮罩层

    同时,我们可能还需要实现初始化方法,如`initWithFrame:`或`initWithCoder:`,以便在创建`MaskView`实例时设置初始属性。 ```objc // MaskView.m #import "MaskView.h" @implementation MaskView - ...

    仿网易自动循环广告,也可手动滑动

    UIImageView imageView [[UIImageView alloc]initWithFrame:self adViewContainerInPersonalView bounds]; imageView image [UIImage imageNamed:[NSString stringWithFormat:@"MQLADPlaceholderPic%d" ...

    iOS实现通过按钮添加和删除控件的方法

    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; [imgView setImage:[UIImage imageNamed:item.imgPath]]; [self.button ...

    ios-点击切换状态の按钮Multi-Button.zip

    MultiButton *btn = [[MultiButton alloc]initWithFrame:CGRectMake(0, 0, 200, 30)]; btn.center = CGPointMake(self.view.center.x, 300); [btn setName:@"volume" state:@"11"]; [self.view addSubview:...

    ios-TitleMenuView.zip

    -(instancetype)initWithFrame:(CGRect)frame WithViewControllers:(NSArray *)array WithStyle:(TitleMenuScrollViewStyle) titleMenuStyle WithTitleFont:(CGFloat)font AndTitleInterval:(CGFloat)space; ...

    IOS点赞效果按钮源代码下载

    CatZanButton *zanBtn=[[CatZanButton alloc] initWithFrame:CGRectMake(0, 0, 50, 50) zanImage:[UIImage imageNamed:@"Zan"] unZanImage:[UIImage imageNamed:@"UnZan"]]; [zanBtn setCenter:self.view.center]; ...

Global site tag (gtag.js) - Google Analytics