Skip to content

Instantly share code, notes, and snippets.

View JigarM's full-sized avatar
🏠
Working from home

Jigar M JigarM

🏠
Working from home
View GitHub Profile
@JigarM
JigarM / ExtendedViewCellRenderer.cs
Last active September 8, 2018 10:08
Disable Xamarin Forms ListView select item HightLight color
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer (typeof(ViewCell), typeof(App.iOS.ExtendedViewCellRenderer))]
namespace App.iOS
{
public class ExtendedViewCellRenderer : ViewCellRenderer
{
public override UIKit.UITableViewCell GetCell (Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
@JigarM
JigarM / ShareviewController.cs
Last active June 1, 2017 07:48
Shre vieew controller Xamarin
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
}
public override void ViewDidAppear (bool animated)
{
try {
base.ViewDidAppear (animated);
@JigarM
JigarM / ShareviewController.cs
Last active June 1, 2017 06:29
Share View Controller of Share Extension Xamarin Version.
public override bool IsContentValid ()
{
// Do validation of contentText and/or NSExtensionContext attachments here
return true;
}
public override void DidSelectPost ()
{
// This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
// Inform the host that we’re done, so it un-blocks its UI.
@JigarM
JigarM / scaleAndrotate.cs
Created January 5, 2017 13:07
Scale and Rotate an image in iOS / MonoTouch, using the EXIF data.
//MIT license
//https://gist.github.com/nicwise/890460
public static UIImage ScaleImage(UIImage image, int maxSize)
{
UIImage res;
using (CGImage imageRef = image.CGImage)
{
CGImageAlphaInfo alphaInfo = imageRef.AlphaInfo;
CGColorSpace colorSpaceInfo = CGColorSpace.CreateDeviceRGB();
@JigarM
JigarM / AttributedTextToHTML.cs
Created December 30, 2016 10:58
Xamarin IOS C# NSAttributedString
//https://forums.xamarin.com/discussion/18460/uitextview-and-html
//https://gist.github.com/adrianstevens/933d66faaea83e165f5f
using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
namespace YourNameSpaceGoesHere
{
public class AttributedTextToHTML
@JigarM
JigarM / UIView-ViewToImage.h
Created November 16, 2016 13:32
Rendering any UIViews into UIImage in one line Raw => From jamztang (https://gist.github.com/jamztang/1578446)
//
//Reference link : https://gist.github.com/jamztang/1578446
//
#import <UIKit/UIKit.h>
@interface UIView (ViewToImage)
// - [UIImage toImage]
//
// Follow device screen scaling. If your view is sized 320 * 480,
using System;
using System.Drawing;
using MonoTouch.CoreGraphics;
/// https://gist.github.com/mayoff/4146780
///https://gist.github.com/pragmatrix/6406094
static class ArrowPath
{
public static CGPath pathWithArrowFromPoint(
@JigarM
JigarM / gist.m
Created July 4, 2016 11:51
Objective-C Auto Set Height of UITextView Raw
// leave the width at 300 otherwise the height wont measure correctly
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10.0f, 0.0f, 300.0f, 100.0f)];
// add text to the UITextView first so we know what size to make it
textView.text = [_dictSelected objectForKey:@"body"];
// get the size of the UITextView based on what it would be with the text
CGFloat fixedWidth = textView.frame.size.width;
CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
CGRect newFrame = textView.frame;
@JigarM
JigarM / file
Last active August 29, 2015 14:24
iOS 8.3 crashes when installing constraints on views.
//A multiplier of 0 or a nil second item together with a location for the first attribute creates
//an illegal constraint of a location equal to a constant. Location attributes must be specified in
//pairs.
// OR
//[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]:
//A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal
//constraint of a location equal to a constant. Location attributes must be specified in pairs'
//Use
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.view1
@JigarM
JigarM / gist:fa9f42bcac231e4af76d
Created April 23, 2015 12:09
Objective-C fastes method for get min and max value from array.
//Original Blog Post : https://gist.github.com/kautaleksei/19afe866371bf3168a3d
#import <Foundation/Foundation.h>
void method1(NSArray *numbers)
{
NSArray *sorted = [numbers sortedArrayUsingSelector:@selector(compare:)];
}
void method2(NSArray *numbers)
{