Using Vector pdf Image in Xamarin IOS - xamarin

In my Xamarin.IOS visual studio project, I wanted to use Vector pdf image in an UIImageView. But I am not able to add the vector image directly in the storyboard designer (also tried drag-drop).
Is there a way to use Vector pdf image in xamarin IOS?
Any sample would be much helpful.
Thanks.

Yes, As lowleetak said, We need to add the pdf file into the asset first.
Xamarin tutorial here , just follow the step ,it's simple.
Edit:
there is no option to select the Attributes Inspector for setting the Scales to Single Vector in Visual Studio. Is there an alternative for this?
AFAIK,there is no option to set the scale for the vector , maybe you could set this property when generate the pdf file.
I want to handle click event to capture the image X Y co-ordinates in C#. Is there a way to do this?
Override the touch event . documentation here.
Code :
public override void TouchesBegan(NSSet touches, UIEvent evt)
{
var touch = touches.AnyObject as UITouch;
CGPoint point = touch.GetPreciseLocation(yourImage);
}
Update:
On iPhone5:
On iPhone6
And this are the constraints

You will need to add the pdf images to asset catalog first (Images.xcassets). You can refer to the guide HERE. It is a guide for Xcode but should be quite the same in Visual Studio.

Related

Resizing image to fit Ui Image View in xcode storyboard

I am trying to fit an image to fit the entire of the Ui Image View. I want to do this because I want to round my image and it does not work because the image is smaller than the entire view. So rounding it rounds the outside of the image and is not visible. I have tried to add constraints but that does not seem to have workout.
Here is an image of what I am trying to do:
https://i.stack.imgur.com/mIGow.png
The problem images:
https://i.stack.imgur.com/LGDyx.png
https://i.stack.imgur.com/K3RVZ.png
OK - the problem is that you don't understand the Xcode interface.
When you have added a UIImageView, set its image, and then select it, you see this:
If you click the image view again, Xcode shows an additional "highlight" outline:
That has nothing to do with how it will look when you run your app.
Regarding the screen-cap from the video you are watching... You either didn't notice, or forgot, two things:
it's a tutorial for SwiftUI - the screen-caps you've posted for what you're trying to do is from a UIKit based app.
at 17:20 of Part 1 of that series, the author explains how he is setting the corner radius.
To get what you want with UIKit, you need to write some code to give the image view rounded corners. To have it show up at design-time, you need to use an #IBDesignable image view subclass.
Here's a very basic example:
#IBDesignable
class RoundedImageView: UIImageView {
override func layoutSubviews() {
layer.cornerRadius = 20
}
}
If you set the Custom Class of your image view to RoundedImageView, and then either select either Editor -> Refresh All Views or have Editor -> Automatically Refresh Designable Views checked, you'll see this:

Xamarin Forms Maps Custom Pin looking like own position

I'm developing a Xamarin.Forms application with a Xamarin.Forms.Map map displaying movable objects. I would like to add my own CustomPin that looks exactly like the Pin showing the own location, without a needle, but maybe with a different color. Is there an easy way to achieve this?
I already found this tutorial on the MS website, which is pretty detailed. But I was hoping there was a way to simply overwrite the default pin (annotation view on iOS) with the view of the user's current position.

How to draw a text on an image and how to use this image as my custom pin icon?

How to draw a text on an image and how to use this image as my custom pin icon?
I use the official code in the https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/map/
I can use the custom pin image as an icon to replace the standard google map pin, but I want to add text on this customized pin, then use my new pin (with the text) to my new customized pin icon.
Here is the code I used now
foreach (var pin in customPins)
{
var marker = new MarkerOptions ();
marker.SetPosition (new LatLng (pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
marker.SetTitle (pin.Pin.Label);
marker.SetSnippet (pin.Pin.Address);
marker.SetIcon (BitmapDescriptorFactory.FromResource (Resource.Drawable.pin));
}
so the maker SetIcon this method to get custom pin icon on my Rouscoure.Drawable folder. In this folder I stored my pin.png image.
I am struggling to draw text in my original pin image. Then, I also don't know how to use SetIcon or InvokeIcon to load my new image if I succeeded add text on my pin.
The main idea is to create a canvas first, then create a paint. After that combine those two together.
There are a lot of Java sample when you google it. The only thing you need to do is how to convert it to Xamarin.Android. It should be easy.
Here is the sample:
https://forums.xamarin.com/discussion/comment/236649/#Comment_236649

Xamarin iOS Slider color

I have a slider in a Xamarin Forms app that I'm trying to change the color of the thumb and the slider bar. In Android it was easy to override this in a renderer, but in iOS it looks like all I can do is change the thumb image. Is it possible to change the bar color? Thanks!
You can use the TintColor:
var slider = new UISlider(View.Frame);
slider.ThumbTintColor = UIColor.Blue;
slider.MinimumTrackTintColor = UIColor.Red;
slider.MaximumTrackTintColor = UIColor.Green;
I also just found a new plugin that does all of that and a lot more. It will probably be overkill for just that but if you plan to do a lot more custom stuff to controls it might be helpful.
I have not tried it myself but I looking forward to using it soon.
XF Gloss

how to get coordinate of control in windows phone 7

i want to know how to get coordinate (x,y) of 2 Textboxes and compare each others, i saw some code use GeoCoordinate then i try it but i don't know why my visual studio doesn't support that library, help me and give me some code example for get (x,y) of controls, i'm using visual studio 2010 and OS 7.1
I think GeoCoordinate is for GPS position, you can't use it to localise control in a grid.
However, you can use this code to localise control relatively to a grid or a stackPanel thank to the code below :
var transform1 = textBox1.TransformToVisual(grid);//Grid is your content panel
Point absolutePosition1 = transform1.Transform(new Point(0, 0));
var transform2 = textBox2.TransformToVisual(grid);//Grid is your content panel
Point absolutePosition2 = transform2.Transform(new Point(0, 0));
After that, you can compare them.

Resources