如何在iOS中使用MApkit在地图中创建圆形覆盖?

时间:2017-02-18 18:08:13

标签: ios mapkit swift3.0.2

我想在注释上创建一个圆形覆盖。我使用的是swift 3.0。任何帮助表示赞赏!!

1 个答案:

答案 0 :(得分:1)

尝试自定义叠加层。在MKCircle *circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:1000]; [map addOverlay:circle]; 中添加:

userLocation

MKUserLocationAnnotation可以通过将- (MKOverlayRenderer *)mapView:(MKMapView *)map viewForOverlay:(id <MKOverlay>)overlay { MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay]; circleView.strokeColor = [UIColor redColor]; circleView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.4]; return circleView; } 存储为属性来获取。然后,要实际绘制圆圈,请将其放在地图视图的委托中:

printf '\n\tInternet speed test:  '

# http://stackoverflow.com/questions/12498304/using-bash-to-display-a-progress-working-indicator

spin[0]="-"
spin[1]="\\"
spin[2]="|"
spin[3]="/"

# http://stackoverflow.com/questions/20165057/executing-bash-loop-while-command-is-running

speedtest > .st.txt &           ## & : continue running script
pid=$!                          ## PID of last command

# If this script is killed, kill 'speedtest':
trap "kill $pid 2> /dev/null" EXIT

# While 'speedtest' is running:
while kill -0 $pid 2> /dev/null; do
for i in "${spin[@]}"
do
    echo -ne "\b$i"
    sleep 0.1
done
done

# Disable the trap on a normal exit:
trap - EXIT

printf "\n\t           "
grep Download: .st.txt
printf "\t             "
grep Upload: .st.txt
echo ''
rm -f st.txt