一,原来的,
- (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小写的不行,