zoukankan      html  css  js  c++  java
  • 计算 star 之间 距离,

    一,原来的,

    - (void)centerIn:(CGRect)_frame with:(int)numberOfStars {

    CGSize size = self.frame.size;

    float height = self.frame.size.height;

    float frameHeight = _frame.size.height;

    float newY = (frameHeight-height)/2;

    float widthOfStars = self.frame.size.width * numberOfStars + 50;

    float frameWidth = _frame.size.width + 15;

    float gapToApply = (frameWidth-widthOfStars)/2;

     self.frame = CGRectMake(size.width*self.tag + gapToApply , newY, size.width, size.height);

    }

     

    方法一, 

    - (void)centerIn:(CGRect)_frame with:(int)numberOfStars {

    CGSize size = self.frame.size;

    float height = self.frame.size.height;

    float frameHeight = _frame.size.height;

    float newY = (frameHeight-height)/2;

     float widthOfStars = self.frame.size.width * numberOfStars + 50;

    float frameWidth = _frame.size.width + 15;

    float gapToApply = (frameWidth-widthOfStars)/2;

    float m_width ;

    int a = self.tag;

            switch (a) {

                case 0:

                    m_width = 0;

                    break;

                case 1:

                    m_width = 13;

                    break;

                case 2:

                    m_width = 37;

                    break;

                case 3:

                    m_width = 50;

                    break;

                case 4:

                    m_width = 76;

                    break;

                case 5:

                    m_width = 89;

                    break;

                case 6:

                    m_width = 116;

                    break;

                case 7:

                    m_width = 129;

                    break;

                case 8:

                    m_width = 155;

                    break;

                default:

                    m_width = 168;

                    break;

            }

           self.frame = CGRectMake(m_width + gapToApply , newY, size.width, size.height);

    }

     

    方法二, 

    - (void)centerIn:(CGRect)_frame with:(int)numberOfStars {

        

    CGSize size = self.frame.size;

    float height = self.frame.size.height;

    float frameHeight = _frame.size.height;

    float newY = (frameHeight-height)/2;

    int temp = self.tag % 2;

    int index = self.tag / 2;

    float margin = 4;

    self.frame = CGRectMake(temp * size.width + index*(size.width*2 + margin), newY, size.width, size.height);

      

    }

    上次计算经纬度的时候,脑袋晕了,这次计算间距的时候 又晕了,好吧,必须承认自己很笨,copy 下来留个纪念吧,

    补充一个:

        NSURLRequest *request = [httpClient requestWithMethod:@"POST" path:FEED_BACK parameters:dic];,post小写的不行,

  • 相关阅读:
    结构体、共用体
    strlen函数,strcat函数,strcpy函数,strncpy函数,strcmp函数
    memmove函数
    Spring Boot——2分钟构建spring web mvc REST风格HelloWorld
    maven3常用命令、java项目搭建、web项目搭建详细图解
    C++中的const关键字
    Pyp 替代sed,awk的文本处理工具
    Python 中的进程、线程、协程、同步、异步、回调
    Python-aiohttp百万并发
    学习Python的三种境界
  • 原文地址:https://www.cnblogs.com/guligei/p/2973973.html
Copyright © 2011-2022 走看看