我的客户要求我根据日期设置不同的MKPlacemarks的不透明度(alpha)。根据日期设置不透明度的算法
对于最早的一半地点标记,他希望不透明度设置为0.5。
我可以通过计算地点标记的索引并检查它是否位于数组的最后一半来完成此操作。
int indexOfPlacemark = [fixes indexOfObject:fix]; //fixes is the array of Placemarks (named fix).
if (index <= [fixes count]/2) {
[annotationView setAlpha:0.5];
} else {
// do something with fix.date to work out the opacity.
// an example of the date is Sun, May 15, 2011 - 12:00:44
}
但是,他希望我根据日期提高其他地方标记的不透明度。即最新日期的不透明度为1.0,阵列前半部分的最早日期为〜0.5。
我想知道的是我如何根据日期确定不透明度。