How to mask UIViews in iOS

I’ve been working on this problem for a couple of hours and have a solution that I think will do what you want. First, create your masking image using whatever means you see fit. Note that we only need the alpha values here, all other colours will be ignored, so make certain that the method … Read more

Simply mask a UIView with a rectangle

Thanks to the link from MSK, this is the way I went with which works well: // Create a mask layer and the frame to determine what will be visible in the view. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; CGRect maskRect = CGRectMake(0, 0, 50, 100); // Create a path with the rectangle in it. … Read more

Mask US phone number string with JavaScript

This answer assumes you want the following format: (000) 000-0000 (as the OP states). There are multiple different ways to implement this, but here are a couple different approaches: If you want to simply mask the number on the blur event (when the field loses focus), then you could use the following: document.getElementById(‘phone’).addEventListener(‘blur’, function (e) … Read more

Converting CIDR address to subnet mask and network address

It is covered by apache utils. See this URL: http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/util/SubnetUtils.html String subnet = “192.168.0.3/31”; SubnetUtils utils = new SubnetUtils(subnet); utils.getInfo().isInRange(address) Note: For use w/ /32 CIDR subnets, for exemple, one needs to add the following declaration : utils.setInclusiveHostCount(true);

Phone mask with jQuery and Masked Input Plugin

Try this – http://jsfiddle.net/dKRGE/3/ $(“#phone”).mask(“(99) 9999?9-9999”); $(“#phone”).on(“blur”, function() { var last = $(this).val().substr( $(this).val().indexOf(“-“) + 1 ); if( last.length == 3 ) { var move = $(this).val().substr( $(this).val().indexOf(“-“) – 1, 1 ); var lastfour = move + last; var first = $(this).val().substr( 0, 9 ); $(this).val( first + ‘-‘ + lastfour ); } });