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小写的不行,

  • 相关阅读:
    再理解HDFS的存储机制
    C实现头插法和尾插法来构建单链表(不带头结点)
    linux系统编程:线程同步-相互排斥量(mutex)
    基于github for windows&github的团队协作基本操作
    分治法求众数问题 (配图)
    hdu1576 mod 运算的逆元
    Android5.0(lollipop)新特性介绍(一)
    jenkins详解(一)
    手机APP测试点总结
    App测试方法总结
  • 原文地址:https://www.cnblogs.com/guligei/p/2973973.html
Copyright © 2011-2022 走看看