w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Setting the CALayer bounds and position from a view controller
The +initialize method is a static method, meaning it affects all instances of that class. Use the -init method (or a custom -init method) to set different bounds for your views. At least I hope I understand your question correctly. Please post some code if this doesn't help

Categories : IOS

Constraints in MATLAB Genetic Algorithm - Not Just Input Constraints
You could use nested functions for your objective and constraint functions. That would allow you to have MATLAB variables (other than the input variables) that are visible to both the objective and constraint functions. This example uses nested functions in order to use results from running a simulation in both the objective and constraint functions. It also shows how to check to see if the simulation needs to be run again, which is necessary if either the objective function or constraint function is called with new values for the input variables.

Categories : Algorithm

Show arrays arranged in a specific format
We need to sort first by number and then by letters. no need for regex here. We will use padding: so ma11 will be 0011ma and mi11 will be 0011mi and ma11 will be 0011ma (and mi9 will be 0009mi , the padding helps 11 to be bigger then 2 as string) so sorting it now - will yield the right result. var a = ["ma9", "ma10", "ma11", "mi9", "mi10", "mi11", "lu9", "lu10", "lu11"] a.sort(function (a, b) { return calc(a) > calc(b); }); function calc(x) { return ("0000" + x.slice(2)).slice(-4) + x.slice(0,2); } result : ["ma9", "ma10", "ma11", "mi9", "mi10", "mi11", "lu9", "lu10", "lu11"]

Categories : Javascript

How can I know if a table is already arranged in ascending order in MySQL?
Data in a table is not arranged in any order. You have to explicitly specify an order when selecting the data. If you do not specify an order when selecting the data then the returned order is neither predictable nor reliable.

Categories : Mysql

Printing integers as a set of 4 bytes arranged in little endian?
For hardware portability, please use the following solution: int freqs[256]; for (int i = 0; i < 256; ++i) printf("%02x %02x %02x %02x ", (freqs[i] >> 0 ) & 0xFF , (freqs[i] >> 8 ) & 0xFF , (freqs[i] >> 16) & 0xFF , (freqs[i] >> 24) & 0xFF);

Categories : C++

Is (n)Hibernate suitable for a model layer with more than 200 classes arranged in a hierarchy?
NHibernate has to resort to that monster of a query because it did not know exactly which table contains the needed data. For example, with session.Get<Vehicle>(100), NHibernate does not know which table contains the data for the vehicle with ID 100, so it will have to join Vehicle, Car, Truck, Bicycle together. But with session.Get<Truck>(100), NHibernate know that data can only resided in Truck table, so the query will be much more efficient, with only one join: Vehicle and Truck. So, if you cannot change your database schema, then I think you have only one option, namely trying to be as specific as possible when querying by always give NHibernate the exact type of entity you need. If you can change your schema, then I think you should try to simplify the model classes, avo

Categories : Database

In Twitter bootstrap, how do I stop divs from being arranged vertically when I decrease the size of my browser?
Don't use row-fluid class on the containing div. just use class="row". Using row-fluid turns on the fluid/adaptive layout that will rearrange the columns based on viewport size. UPDATE Have a read here http://twitter.github.io/bootstrap/scaffolding.html#gridSystem this explains how the grid system works. Are you including the responsive CSS file? If so, simply removing it should make it stop that.

Categories : HTML

List EMPNAME, PHONE, EMAIL for temporary or part time staff getting salary between 30000-50000 - arranged according to CITY, FACULTY and EMPID
You can order by a value that is not one of the fields selected. A Group By is not needed for this query. The query below (which is essentially what you have posted) will work. This assumes both temporary and part time workers are identified by 'PT'. SELECT empname, phone, email from employee where emptype = 'PT' and salary between 30000 and 50000 order by city, faculty, empid; Do both part time and temporary workers have the same empTpype? If not, you need something like this: select empname, phone, email from employee where ( emptype = 'PT' OR emptype = 'TEMP' ) and salary between 30000 and 50000 order by city, faculty, empid

Categories : SQL

Associate Array / Key Pair Array In Javascript arranged in with random order of keys.
Looks to me as if your using an object. The sorting of an object's properties is never guaranteed. I don't think internet explorer (at least the old versions) sorts the properties but chrome does by default. Your code is invalid, it should have the properties as strings if they are not numbers. And you would have to use an object a = {}; a["T1001"] ="B" a["T1005"] = "A" a["T1003"] ="C" You can either use two arrays to store your properties and the value if you want to preserve the ordering, or you cannot guarantee the ordering if you insist on using an object. Two arrays a1 = []; a2 = [] a1[0] = "T1001"; a2[0] = "B"; a1[1] = "T1005"; a2[1] = "A"; a1[2] = "T1003"; a2[2] = "C"; EDIT: Unless I guessed at what you meant wrong and that T1001, etc are variables containing numbers.

Categories : Javascript

Can i stop or start the html marquee when hovering on the images which are arranged in that marquee?
Yes You can start or stop marquee on mouse over and out here is html code <marquee direction="left" onmouseover="this.stop()" onmouseout="this.start()" scrollamount="3"> <img src="imageurl.jpg /> <img src="imageurl.jpg /> <img src="imageurl.jpg /> <img src="imageurl.jpg /> <img src="imageurl.jpg /> </marquee>

Categories : HTML

Drawing line on a CALayer in OSx
Ok, I have found. set the layer's delegate override this method in the delegate call layer setNeedDisplay method when you need - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:NO]; [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:gc]; // draw points with bezier path [NSGraphicsContext restoreGraphicsState]; }

Categories : Objective C

CALayer's image not showing up
either use this layer = [[CALayer alloc] init]; [self.view.layer addSublayer:layer]; //UIImage *image = [UIImage imageNamed:@"download.jpeg"]; layer.bounds = CGRectMake(0, 0, 300,300); layer.position = self.view.center; //layer.contents = (id)image.CGImage; layer.contents = (id)[UIImage imageNamed:@"download.jpeg"].CGImage; [layer setNeedsDisplay]; or remove [layer setNeedsDisplay]; I guess the setNeedsDisplay made the layer to redraw the content and so deleting the image. --

Categories : IOS

Scaling CALayer up from bottom. (Not top)
You just need to modify the y origin of your layer at the same time that you modify the height. I don't know exactly what your code looks like, but if you're taking the old frame and applying a constant change to the width and height, like this: CGRect newFrame = oldFrame; newFrame.size.width += kWidthChange; newFrame.size.height += kHeightChange; _myLayer.frame = newFrame; then you just need one more line, like: newFrame.origin.y -= kHeightChange; before you reassign the layer's frame.

Categories : Objective C

Method sent to CAEmitterLayer but goes to CALayer
I'm assuming this code is within a custom UIView, if so, make sure that you have overridden: + (Class)layerClass So it should be: + (Class)layerClass { return [CAEmitterLayer class]; } This will ensure that inside your UIView where you have emitter = (CAEmitterLayer*)self.layer; It is returning a CAEmitterLayer, rather than a normal CALayer which it does by default. I'm guessing this is the issue since the error is stating you are trying to call a method that only exists on CAEmitterLayer on a normal CALayer.

Categories : Iphone

CALayer background color
Coregraphics gradient layers are much better then CALayer. CALayer is slow and will show the gradient bands while coregraphics will have a smooth gradient. This is probably why it is happening to you. Create a -(void)drawRect:(CGRect)rect { function and draw your gradient under there. It should take care of your issue. There is a lot of sample code out there for this. Here is some CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGFloat locations[] = { 0.0, 1.0 }; NSArray *colors = @[(__bridge id) startColor, (__bridge id) endColor]; CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef) colors, locations);

Categories : IOS

What is the best way to hide a CALayer (without animation)?
CALayer has a property called "hidden", try setting that to YES and NO instead of switching opacities. Layer to hide: [layer setHidden:YES]; Layer to show: [layer setHidden:NO]; Hope this helps you.

Categories : IOS

Masking CALayer with Lines
I ended up solving this by forgetting about using masks. Instead, I just constructed a UIBezierPath using the moveToPoint: and addLineToPoint: methods in order to draw the desired portions of the circle.

Categories : IOS

Override opacity of a CALayer set in xib
If you need to need an animation only during selection and highlighting, remove the animation in -cellForRowAtIndexPath because this called when the tableview needs a cell, not displaying . Subclass as Dinesh said UITableViewCellClass and override -setSelected: setHighlighted:. Do not use layers unless you really have to (and it will happened in less of 20% of cases), UIView class has everything you need to do this kind of animation using simple animations block, layers introduce more concept about modalLayer and presentationLayer in animation. Pay attention where you are adding views, UITableViewCell use a -contentView as container for your subviews. If you want to know when UITableView is showing/selecting/dismissing a cell use the UITableViewDelegateProtocol it has a lot of methods th

Categories : IOS

How to remove a CALayer's mask?
You did not provide enough information. Who owns your captionTextField? Post the code that shows how you create your captionTextField, and where you store it. You need to save a strong reference to it somewhere (strong instance variable or property) or it will indeed get released as soon as nobody holds onto it. It does not make sense that setting your wallpaperImageView's layer's mask to nil is causing your captionTextField to be released, unless you create your captionTextField and don't keep a strong reference to it.

Categories : Iphone

How can i solve CALayer exception?
A NaN means "Not a Number". You may also sometimes see inf, which stands for "infinity". This happens when floating point calculations result in an infinity or an undefined value. Usually it's the result of either a divide by 0 error or an uninitialized variable. It means that at some point, you're setting your CALayer's position to an invalid floating point value. You can check values for NaNs by calling the standard C macro isnan(), though according to this page, it's not portable. FWIW, I've had good luck using it. (There's also an isinf() macro for checking for infinities.) You might also have luck using the static analyzer to see if you have any uninitialized variables. (Or turn on the compiler warning for uninitialized variables if it's not already on.)

Categories : IOS

MonoTouch CALayer BackgroundFilters
From the Core Animation Programming Guide Platform Note: In iOS, the backgroundFilters property is exposed in the CALayer class but the filters you assign to this property are ignored.

Categories : IOS

Solid border for CALayer
change the shadowOffset value and check change the shadow color to other than white myLayer.shadowOffset = CGSizeMake(X,X); (X = any value that suits to your requirement) e.g. myLayer.shadowOffset = CGSizeMake(0,2);

Categories : IOS

When do I need to set the contentsScale property of a CALayer?
On OS X you basically grab your window’s -backingScaleFactor set each (!) layer’s -contentsScale to that scaleFactor implement -layer:shouldInheritContentsScale:fromWindow: in a controller set each layer’s -delegate to that controller I know it’s frowned upon here on SO to just reference an external URL, but it’s hard to describe this. Here is some code that works correctly for me with regard to the scale factors: https://github.com/JanX2/ScrollingAboutWindow Hope that helps.

Categories : IOS

Stroke masked CALayer in iOS
You're on the right track with the shape layer. But you should have two different layers. First the mask layer as in your first example which masks your view (cuts off areas you don't want to be visible) Then you add the shape layer too, but not as mask layer. Also, make sure to not use borderWidth and borderColor, but stroke. // // Create your mask first // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.label.bounds byRoundingCorners:UIRectCornerBottomRight cornerRadii:CGSizeMake(16.0f, 16.0f)]; CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = self.label.bounds; maskLayer.path = maskPath.CGPath; self.label.layer.mask = maskLayer; // // And then create the outli

Categories : IOS

How to blur image using CALayer
The documentation of the backgroundFilters property says this: Special Considerations This property is not supported on layers in iOS. As of iOS 6.1, there is no public API for applying live filters to layers on iOS. You can write code to draw the underlying layers to a CGImage and then apply filters to that image and set it as your layer's background, but doing so is somewhat complex and isn't “live” (it doesn't update automatically if the underlying layers change).

Categories : IOS

Difference drawing on CALayer and UIView
This is due to the contentsScale property. When you have a custom CALayer the default value of this property is 1.0. The default value of this property is 1.0. For layers attached to a view, the view changes the scale factor automatically to a value that is appropriate for the current screen. For layers you create and manage yourself, you must set the value of this property yourself based on the resolution of the screen and the content you are providing. Core Animation uses the value you specify as a cue to determine how to render your content. Source. If you have a retina device and you draw with the contentsScale set to 1.0, it will result in that pixelated look you described. In order to fix this you should set the layer's contentsScale to the one of the screen. [self

Categories : IOS

CaLayer performance with animating pie chart
Core Plot This open-source project may bring some thoughts about perfomance. I've used this with animations in production and have great results

Categories : IOS

Using UISlider to change CALayer values
You need to connect the the slider's value changed event to your IBAction. You also need to keep instance to your sublayer so you can refer to it from outside of viewDidLoad. In viewDidLoad add: // Call adjustValue: when the slider value changes [slider addTarget:self action:@selector(adjustValue:) forControlEvents:UIControlEventValueChanged]; // create and configure sub layer ... self.mysublayer = sublayer; Then in the IBAction you can modify your layer: - (IBAction)adjustValue:(UISlider *)sender { float value = [sender value]; // Modify layer here. self.mysublayer.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:value].CGColor; } Hope this helps!

Categories : Objective C

UIView reflect CALayer properties
On iOS, views are fairly thin wrappers around layers, and most view properties like the frame/bounds, alpha, etc. are indeed just manipulating the underlying layer. You can verify your alpha example with a little snippet of code in a view controller: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.view.alpha = 0.5f; NSLog(@"Layer alpha: %f", self.view.layer.opacity); self.view.layer.opacity = 1.0f; NSLog(@"View alpha: %f", self.view.alpha); } This prints out: Layer alpha: 0.500000 View alpha: 1.000000 So we can see that the view alpha and layer opacity are the same thing.

Categories : Iphone

Zooming CALayer blurs the view
I had a similar experience when zooming in content. When a UIScrollView is zooming, it takes a snapshot of the View, and zooms in on that picture. This is the reason it gets blocky when zooming. When the zooming/panning is complete, use the delegate to re-render the content according to your zoom level. The content then should be 'crisp'. Warning: do not zoom in too far, the memory used by the snapshot will soon be larger than your available memory. I didn't use images, but CAShapeLayers and paths. I put together a demo project and explanation here : http://simplicate.weebly.com/1/post/2013/06/fixing-blocky-paths-in-ios.html I hope that helps.

Categories : IOS

What does setting CALayer's bounds.origin do?
Changing the bounds rectangle changes the position and size of the content in the coordinate system of the layer itself. Changing the frame (or position) changes the position of the layer in the coordinate system of its super layer. Usually you only want to change the frame, not the bounds.

Categories : IOS

CALayer subclass not animating to property changes
If animAngle is a @property - you must specify accessors for this property. When you mark property as @dynamic this means, that you will provide an implementation of those methods dynamically at runtime. So, if you do not provide accessors for property, you can't access it.

Categories : IOS

Change CALayer color while animating
I'm not 100% clear on what you want here, but if the goal is just for the whole stroke to change color as it draws, but in three discrete stages, then I would propose adding the following. I cooked up these examples in a default "Single View Application" template. I've got a button set up with its action pointing at -doStuff:. If the whole stroke color were to change, it might look something like this: To produce that, the code looked like: @implementation MyViewController { CAShapeLayer* mLayer; } - (IBAction)doStuff:(id)sender { const NSUInteger numSegments = 3; const CFTimeInterval duration = 2; [mLayer removeFromSuperlayer]; mLayer = [[CAShapeLayer alloc] init]; mLayer.frame = CGRectInset(self.view.bounds, 100, 200); mLayer.fillColor = [[UIColor purpl

Categories : Objective C

CALayer's shouldRasterize vs UIView's drawRect?
shouldRasterize caches the drawn layer and all of its sublayers into a single bitmap context. drawRect just provides bitmap content for an individual layer. Note that setting shouldRasterize on the layer does not affect how the layer is drawn; it affects what happens after those pixels are drawn. You can use these options independently or together; they provide different functionality.

Categories : IOS

Strange behaviour of rotation transform for CALayer
Found the reason myself: it was because in parallel I moved layer using .frame instead of .position property: frame property itself is calculated based on transform thus setting it produced that 'crazy' behavior.

Categories : IOS

Setting mask on CALayer breaks hitTest
It turns out that hit testing requires the point to be inside the bounds of the CALayer, but what is not documented is that it also has to be inside the bounds of the mask. So I changed my code like this and it worked: _theLayer.frame = CGRectMake(0, 0, size.width, size.height); // Apply a mask _maskLayer.frame = _theLayer.frame; _theLayer.mask = _maskLayer; It took me a few hours to figure this out, so I wanted to share.

Categories : Misc

Animate UIView frame with CALayer as subview
You'll have to understand that the UIView and CALayer hierarchy are different. Layout changes and animations operating on a UIView will not automatically affect the CALayer hierarchy. So if you want changes applied to your view affect a layer you'll have to update that yourself. Your code is also missing details. For example you claim you see your gradient layer change it's frame, but you don't show where you are changing it. Did you overwrite layoutSubviews somewhere to update it's frame? By default updating a layer frame will trigger it's implicit animations for the position & bounds properties. To change the speed of the animation you could use: [CATransaction begin]; [CATransaction setAnimationDuration:10.0]; _myLayer.frame = newFrame; [CATransaction commit];

Categories : Iphone

CALayer border width resizes when zooming
Instead of using CALayer, try using CATiledLayer. This class is aware of scaling. You can use the properties levelsOfDetail and levelsOfDetailsBias to set the resolution your view needs. I'm not sure if this will solve your problem but I think it's worth trying. Hope it helps!

Categories : IOS

CALayer::hitTest failing in landscape orientation
It has nothing to do with orientation. According to apple docs, "hitTest Returns the farthest descendant of the layer". Siblings are searched in top-to-bottom order. the touch point is in the coordinate system of the receiver's superlayer. So add this line immediately after you get the touchPoint. i.e CGPoint touchPoint = [[touches anyObject] locationInView:self.view]; touchPoint = [self.view.layer convertPoint:touchPoint toLayer:self.view.layer.superlayer]; ...........

Categories : Iphone

Moving CALayer's mask on scroll in a Scrollview
CALayer are implicit animated for some properties like position try to disable them: - (void)scrollViewDidScroll:(UIScrollView *)scrollView { [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; CGPoint contentOffset = scrollView.contentOffset; contentOffset.y = -contentOffset.y; self.overlayImageView.viewlayer.mask.position = contentOffset; [CATransaction commit]; }

Categories : IOS



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.