My client has asked me to set the opacity (alpha) for various different MKPlacemarks depending on what the date was.
For the oldest half of the place marks, he would like the opacity to be set to 0.5.
I can do this by working out the index of the place mark and checking to see whether it is in the last half of the array.
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
}
But then he wants me to raise the opacity for every other place mark depending on its date. I.e the latest date will have an opacity of 1.0, and the oldest date in the first half of the array will be ~0.5.
What I would like to know is how I can work out the opacity depending on its date.
if we’ll relate to the date as a long value, then the oldest date and the newest date form an Interval, this Interval can be rescaled and moved.
try this method