Tutorial by Examples

Basics There are a number of different transforms you can do on a layer, but the basic ones are translate (move) scale rotate To do transforms on a CALayer, you set the layer's transform property to a CATransform3D type. For example, to translate a layer, you would do something like this:...
CALayer property animations are enabled by default. When this is undesirable, they can be disabled as follows. Swift CATransaction.begin() CATransaction.setDisableActions(true) // change layer properties that you don't want to animate CATransaction.commit() Objective-C [CATransaction be...
You can test that a function throws an exception with the built-in unittest through two different methods. Using a context manager def division_function(dividend, divisor): return dividend / divisor class MyTestCase(unittest.TestCase): def test_using_context_manager(self): ...
Xposed is a framework that allows you to hook method calls of other apps. When you do a modification by decompiling an APK, you can insert/change commands directly wherever you want. However, you will need to recompile/sign the APK afterwards and you can only distribute the whole package. With Xpose...
Create a new class implementing IXposedHookLoadPackage and implement the handleLoadPackage method: public class MultiPatcher implements IXposedHookLoadPackage { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { ...
In an iOS app, your user interface can take on one of a few different general shapes and sizes. These are defined using size classes, which are available through a view or view controller's trait collection. Apple defines two size classes: regular and compact. Each of these size classes are availab...
Making an app adaptive – that is, responding to size class changes by changing your layout – often involves lots of help from the Auto Layout system. One of the primary ways apps become adaptive is by updating the active Auto Layout constraints when a view's size class changes. For example, conside...
A key piece of adaptivity in a modern iOS app is supporting multitasking on iPad. By default, apps created in Xcode 7 and newer will be configured to support multitasking: they'll have a LaunchScreen.storyboard file that uses Auto Layout. The easiest way for existing apps to opt in to multitasking ...
void alertDialogDemo() { // get alert_dialog.xml view LayoutInflater li = LayoutInflater.from(getApplicationContext()); View promptsView = li.inflate(R.layout.alert_dialog, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( ...
String literals are used to specify arrays of characters. They are sequences of characters enclosed within double quotes (e.g. "abcd" and have the type char*). The L prefix makes the literal a wide character array, of type wchar_t*. For example, L"abcd". Since C11, there are ot...
Floating point literals are used to represent signed real numbers. The following suffixes can be used to specify type of a literal: SuffixTypeExamplesnonedouble3.1415926 -3E6f, Ffloat3.1415926f 2.1E-6Fl, Llong double3.1415926L 1E126L In order to use these suffixes, the literal must be a floating p...
Character literals are a special type of integer literals that are used to represent one character. They are enclosed in single quotes, e.g. 'a' and have the type int. The value of the literal is an integer value according to the machine's character set. They do not allow suffixes. The L prefix bef...
Considering a (post)model: public class User { public string FirstName { get; set; } public bool IsAdmin { get; set; } } With a view like so: @using (Html.BeginForm()) { @Html.EditorFor(model => model.FirstName) <input type="submit" value="Save" /...
Suppose we want to have a route that allows an unbound number of segments like so: http://example.com/Products/ (view all products) http://example.com/Products/IT http://example.com/Products/IT/Laptops http://example.com/Products/IT/Laptops/Ultrabook http://example.com/Products/IT/Laptops/Ult...
The following is a list of tips for those who are looking to contribute to the PHP manual: Follow the manual's style guidelines. Ensure that the manual's style guidelines are always being followed for consistency's sake. Perform spelling and grammar checks. Ensure proper spelling and grammar is ...
Sometimes the shell prompt doesn't display the name of the virtual environment and you want to be sure if you are in a virtual environment or not. Run the python interpreter and try: import sys sys.prefix sys.real_prefix Outside a virtual, environment sys.prefix will point to the system p...
There are a few ways to use functions. Calling a function with an assignment statement DECLARE x NUMBER := functionName(); --functions can be called in declaration section BEGIN x := functionName(); END; Calling a function in IF statement IF functionName() = 100 THEN Null; EN...
When executing a Bash script, parameters passed into the script are named in accordance to their position: $1 is the name of the first parameter, $2 is the name of the second parameter, and so on. A missing parameter simply evaluates to an empty string. Checking for the existence of a parameter can...
There are some functions to help tear down Free computations by interpreting them into another monad m: iterM :: (Functor f, Monad m) => (f (m a) -> m a) -> (Free f a -> m a) and foldFree :: Monad m => (forall x. f x -> m x) -> (Free f a -> m a). What are they doing? First l...
Interfaces can seem abstract until you seem them in practice. The IComparable and IComparable<T> are great examples of why interfaces can be helpful to us. Let's say that in a program for a online store, we have a variety of items you can buy. Each item has a name, an ID number, and a price. ...

Page 629 of 1336