zoukankan      html  css  js  c++  java
  • IOS 类方法

    1.新建一个类 继承自UIView

    重写UIView 里面的方法

        CGRect bounds=[self bounds];
       
    CGPoint center;
       
    center.x=bounds.origin.x+bounds.size.width/2.0;
     
       center.y=bounds.origin.y+bounds.size.height/2.0;
     
       float maxRadius=hypot(bounds.size.width, bounds.size.height)/2.0;
     
       CGContextRef content=UIGraphicsGetCurrentContext();
       

        CGContextSetLineWidth(content, 10);
      
      [[UIColor lightGrayColor]setStroke];
       
    for(float currentRadis=maxRadius;currentRadis>0;currentRadis-=20)
       
    {
        
       
           
    CGContextAddArc(content, center.x, center.y, currentRadis, 0.0, M_PI*2.0, YES);
       
         CGContextStrokePath(content);
       
    }
       
      
      NSString *text=[[NSString alloc]initWithString:@"bin ge wei wu"];
      
      UIFont  *font=[UIFont boldSystemFontOfSize:28];
       

        CGRect textRect;
        textRect.size=[text sizeWithFont:font];
       
    textRect.origin.x=center.x-textRect.size.width/2.0;
     
       textRect.origin.y=center.y-textRect.size.height/2.0;
      
      [[UIColor blackColor]setFill];
       
    CGSize offset=CGSizeMake(4, 3);
      
      CGColorRef color=[[UIColor darkGrayColor]CGColor];
     
      CGContextSetShadowWithColor(content, offset, 2.0,color);
      
      [text drawInRect:textRect withFont:font];
       

    在.m文件里面使用

        UIView *backview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
        CGRect wholewindwos=[backview bounds];
        view=[[hypnosisview alloc]initWithFrame:wholewindwos];
      
        [ backview addSubview:view];
        
        [self.view addSubview:backview];
  • 相关阅读:
    hexo常用命令笔记
    给hexo添加评论系统
    npm 使用代理
    几种网页重定向(自动跳转)的方法
    使用hexo搭建github博客
    在Pythonanywhere上部署Django
    Apache .htaccess语法之RewriteRule
    为Github项目创建文档
    Windows下WordPress搭建博客过程
    Windows下Discuz搭建论坛过程
  • 原文地址:https://www.cnblogs.com/zhibin/p/2727235.html
Copyright © 2011-2022 走看看