大佬教程收集整理的这篇文章主要介绍了ios – 在MKMapView上添加具有模糊效果的圈子,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个类从MKCircleRenderer扩展,我想在它覆盖的地图上添加一个模糊效果.
我正在尝试使用-fillPath:inContext:方法,但是我对Core Graphics和Core @L_502_0@的无知导致我无处不在,我真的很失落了这个问题.
我试图使用CIFilter,因此我需要一个CIImage,我试图从上下文创建.但是我发现没有办法从上下文创建一个CGBitmapContext,CGImage和任何其他类.我尝试的任何方法导致了NULL,没有进一步的细节为什么.我不记得我试过的所有,所以我很抱歉没有指出任何事情.
- (instanCETypE)initWithOverlay:(id<MKOverlay>)overlay { if (self = [super initWithOverlay:overlay]) { self.@L_616_17@Color = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1]; self.fillColor = [UIColor colorWithRed:0.4 green:0.2 blue:0.2 alpha:0.1]; self.lineWidth = 1; } return self; }
另一种可能是使用@L_848_18@mKAnnotation,并使用UIVisualEffectView在视图中添加模糊效果.这种方法的难点在于缩放时会增大/减小大小.
这应该适用于iOS 8
编辑
在这种情况下,圆圈内侧的地图应该模糊
一个很简单,你可以使用图像
您@R_276_9381@以下图像很有用:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) Annotation { // ... get the Annotation delegate and allocate the MKAnnotationView (AnnView) if ([AnnotationDelegate.type localizedCaseInsensitiveCompare:@"NeedsBluePin"] == NSorderedSamE) { UIImage * image = [UIImage imagenamed:@"blue_pin.png"]; UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease]; [AnnView addSubview:imageView]; } }
其他方法以编程方式进行[让自己圈]
这是代码可以帮助你.
import UIKit import AddressBook import AddressBookUI import MapKit import CoreLOCATIOn import messageUI import Social class ViewController: UIViewController,ABPeoplePickerNavigationControllerDelegate,MFMailComposeViewControllerDelegate,MKMapViewDelegate { @IBOutlet weak var name: UILabel! @IBOutlet weak var email: UILabel! @IBOutlet weak var photo: UIImageView! @IBOutlet weak var map: MKMapView! let lOCMan:CLLOCATIOnManager=CLLOCATIOnManager() // Blurring Code @IBOutlet weak var labelBACkground: UIView! var BACkgroundBlur: UIVisualEffectView! @IBACtion func newBFF(sender: AnyObject) { let picker: ABPeoplePickerNavigationController = ABPeoplePickerNavigationController() picker.peoplePickerDelegate = self presentViewController(picker,animated: true,completion: nil) } @IBACtion func sendEmail(sender: AnyObject) { var emailAddresses:[String]=[self.email.text!] var mailComposer:MFMailComposeViewController = MFMailComposeViewController() mailComposer.mailComposeDelegate=self; mailComposer.setToRecipients(emailAddresses) presentViewController(mailComposer,completion: nil) } func mailComposeController(controller: MFMailComposeViewController!,didFinishWithResult result: MFMailComposeResult,error: NSError!) { dismissviewControllerAnimated(true,completion: nil) } func peoplePickerNavigationController(peoplePicker: ABPeoplePickerNavigationController!,didSELEctPerson person: ABRecord!) { let friendName:string = ABRecordCopyValue(person,kABPersonFirstNameProperty).takeRetainedValue() as String as String name.text=friendName let friendAddressSet:ABMultiValueRef = ABRecordCopyValue(person,kABPersonAddressProperty).takeRetainedValue() if ABMultiValueGetCount(friendAddressSet)>0 { let friendFirstAddress: Dictionary = ABMultiValueCopyValueATindex(friendAddressSet,0).takeRetainedValue() as NSDictionary showAddress(friendFirstAddress) } let friendEmailAddresses:ABMultiValueRef = ABRecordCopyValue(person,kABPersonEmailProperty).takeRetainedValue() if ABMultiValueGetCount(friendEmailAddresses)>0 { let friendEmail: String = ABMultiValueCopyValueATindex(friendEmailAddresses,0).takeRetainedValue() as String email.text=friendEmail } if ABPersonHasImageData(person) { photo.image = UIImage(data: ABPersonCopyImageData(person).takeRetainedValue()) } } func showAddress(fullAddress:NSDictionary) { let geocoder: CLGeocoder = CLGeocoder() geocoder.geocodeAddressDictionary(fullAddress,completionHandler: {(placemarks: [AnyObject]!,error: NSError!) -> Void in let friendPlacemark:CLPlacemark = placemarks[0] as CLPlacemark let mapRegion:MKCoordinateRegion = MKCoordinateRegion(center: friendPlacemark.LOCATIOn.coordinate,span: MKCoordinateSpanMake(0.2,0.2)) self.map.setRegion(mapRegion,animated: truE) let mapPlacemark: MKPlacemark = MKPlacemark(placemark: friendPlacemark) self.map.addAnnotation(mapPlacemark) }) } func mapView(aMapView: MKMapView!,viewForAnnotation Annotation: MKAnnotation!) -> MKAnnotationView! { let pinDrop:MKPinAnnotationView = MKPinAnnotationView(Annotation: Annotation,reusEIDentifier: "myspot") pinDrop.animatesDrop=true pinDrop.canShowCallout=true pinDrop.pinColor=MKPinAnnotationColor.Purple return pinDrop } @IBACtion func sendTweet(sender: AnyObject) { let geocoder: CLGeocoder = CLGeocoder() geocoder.reverseGeocodeLOCATIOn(map.userLOCATIOn.LOCATIOn,error: NSError!) -> Void in let myPlacemark:CLPlacemark = placemarks[0] as CLPlacemark let tweetText:string = "Hello all - I'm currently in \(myPlacemark.locality)!" let tweetComposer: SLComposeViewController = SLComposeViewController(forserviCEType: SLserviCETypeTwitter) if SLComposeViewController.isAvailableForserviCEType(SLserviCETypeTwitter) { tweetComposer.seTinitialText(tweetText) self.presentViewController(tweetComposer,completion: nil) } }) } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,typically from a nib. //let lOCMan:CLLOCATIOnManager=CLLOCATIOnManager() lOCMan.requestWhenInUseAuthorization() let blur: UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light) BACkgroundBlur = UIVisualEffectView (effect: blur) BACkgroundBlur.frame = labelBACkground.frame view.insertSubview(BACkgroundBlur,belowSubview: labelBACkground) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } override func preferredStatusBarStyle() -> UIStatusBarStyle { return UIStatusBarStyle.Lightcontent } }
以上是大佬教程为你收集整理的ios – 在MKMapView上添加具有模糊效果的圈子全部内容,希望文章能够帮你解决ios – 在MKMapView上添加具有模糊效果的圈子所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。